-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CullLeaves 3.0.0 - Forge support & better Sodium compatibility
- Now utilizes the Architectury build system to provide support for Fabric, native Quilt and even Forge (No Architectury API needed!) - Update to MidnightLib 1.0.0 - Better Sodium/Rubidium support: - Fix resourcepacks utilizing leaf culling flickering when using Sodium (Fixes #15) - Integrate Leaf Culling toggle into Sodium options screen
- Loading branch information
Showing
23 changed files
with
160 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ out/ | |
output/ | ||
bin/ | ||
libs/ | ||
.architectury-transformer/ | ||
|
||
.classpath | ||
.project | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
common/src/main/java/eu/midnightdust/cullleaves/mixin/MixinRegionChunkRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package eu.midnightdust.cullleaves.mixin; | ||
|
||
import eu.midnightdust.cullleaves.config.CullLeavesConfig; | ||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; | ||
import me.jellysquid.mods.sodium.client.gl.util.ElementRange; | ||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing; | ||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType; | ||
import me.jellysquid.mods.sodium.client.render.chunk.*; | ||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(value = RegionChunkRenderer.class, remap = false) | ||
public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer { | ||
@Shadow @Final private boolean isBlockFaceCullingEnabled; | ||
@Shadow protected abstract void addDrawCall(ElementRange part, long baseIndexPointer, int baseVertexIndex); | ||
@Unique private boolean doFix = false; | ||
|
||
public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) { | ||
super(device, vertexType); | ||
} | ||
|
||
@Inject(method = "buildDrawBatches", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;getBounds()Lme/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderBounds;", ordinal = 0)) | ||
public void cullleaves$shouldApplyTransparentBlockFaceCullingFix(List<RenderSection> sections, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfoReturnable<Boolean> cir) { | ||
doFix = pass.getAlphaCutoff() != 0 && CullLeavesConfig.enabled && CullLeavesConfig.sodiumBlockFaceCullingFix && this.isBlockFaceCullingEnabled; | ||
} | ||
@Redirect(method = "buildDrawBatches", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/ChunkGraphicsState;getModelPart(Lme/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFacing;)Lme/jellysquid/mods/sodium/client/gl/util/ElementRange;", ordinal = 0)) | ||
public ElementRange cullleaves$fixTransparentBlockFaceCulling(ChunkGraphicsState state, ModelQuadFacing facing) { | ||
if (doFix) { | ||
long indexOffset = state.getIndexSegment().getOffset(); | ||
int baseVertex = state.getVertexSegment().getOffset() / this.vertexFormat.getStride(); | ||
for (ModelQuadFacing direction : ModelQuadFacing.DIRECTIONS) { | ||
this.addDrawCall(state.getModelPart(direction), indexOffset, baseVertex); | ||
} | ||
} | ||
return state.getModelPart(ModelQuadFacing.UNASSIGNED); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
common/src/main/java/eu/midnightdust/cullleaves/mixin/MixinSodiumGameOptionPages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package eu.midnightdust.cullleaves.mixin; | ||
|
||
import eu.midnightdust.cullleaves.config.CullLeavesConfig; | ||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; | ||
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl; | ||
import me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(value = SodiumGameOptionPages.class, remap = false) | ||
public class MixinSodiumGameOptionPages { | ||
|
||
@Shadow @Final private static SodiumOptionsStorage sodiumOpts; | ||
|
||
@ModifyVariable(method = "performance", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;")) | ||
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) { | ||
groups.add(OptionGroup.createBuilder() | ||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts) | ||
.setName(Text.translatable("cullleaves.midnightconfig.enabled")) | ||
.setTooltip(Text.translatable("cullleaves.midnightconfig.enabled.tooltip.sodium")) | ||
.setControl(TickBoxControl::new) | ||
.setBinding((opts, value) -> { | ||
CullLeavesConfig.enabled = value; | ||
CullLeavesConfig.write("cullleaves"); | ||
}, opts -> CullLeavesConfig.enabled) | ||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) | ||
.setImpact(OptionImpact.MEDIUM) | ||
.build() | ||
) | ||
.build() | ||
); | ||
|
||
return groups; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"cullleaves.midnightconfig.title":"Cull Leaves Config", | ||
"cullleaves.midnightconfig.enabled.tooltip":"After changing this setting you have to reload all chunks (F3 + A)", | ||
"cullleaves.midnightconfig.enabled":"Enabled" | ||
"cullleaves.midnightconfig.enabled.tooltip":"Enables culling for leaves, providing a nice performance boost.\n§cAfter changing this setting you have to reload all chunks (F3 + A)", | ||
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Enables culling for leaves, providing a nice performance boost", | ||
"cullleaves.midnightconfig.enabled":"Enable Leaf Culling", | ||
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix.tooltip": "Fixes resourcepacks utilizing leaf culling flickering when using Sodium.\nYou probably want this to be enabled.", | ||
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix": "Fix Sodium Block Face Culling on Leaves" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"cullleaves.midnightconfig.title":"Definições do Cull Leaves", | ||
"cullleaves.midnightconfig.enabled.tooltip":"Recarregue os chunks (F3 + A) ao alterar essa opção", | ||
"cullleaves.midnightconfig.enabled":"Ativado" | ||
"cullleaves.midnightconfig.enabled":"Ativado Cull Leaves" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"cullleaves.midnightconfig.title":"Настройки Cull Leaves", | ||
"cullleaves.midnightconfig.enabled.tooltip":"После изменения этого параметра необходимо перезагрузить чанки (F3 + A)", | ||
"cullleaves.midnightconfig.enabled":"Включён" | ||
"cullleaves.midnightconfig.enabled":"Включён Cull Leaves" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ces/resourcepacks/smartleaves/license.txt → ...ces/resourcepacks/smartleaves/license.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
common/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pack": { | ||
"pack_format": 9, | ||
"description": "§2Makes leaves look identical to OptiFine's smart leaves" | ||
} | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
fabric-like/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
forge/src/main/java/eu/midnightdust/cullleaves/forge/CullLeavesClientEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package eu.midnightdust.cullleaves.forge; | ||
|
||
import net.minecraft.resource.*; | ||
import net.minecraft.resource.metadata.PackResourceMetadata; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.event.AddPackFindersEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.ModList; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.forgespi.locating.IModFile; | ||
import net.minecraftforge.resource.PathPackResources; | ||
|
||
import java.io.IOException; | ||
|
||
@Mod.EventBusSubscriber(modid = "cullleaves", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) | ||
public class CullLeavesClientEvents { | ||
@SubscribeEvent | ||
public static void addPackFinders(AddPackFindersEvent event) { | ||
if (event.getPackType() == ResourceType.CLIENT_RESOURCES) { | ||
registerResourcePack(event, new Identifier("cullleaves", "smartleaves"), false); | ||
} | ||
} | ||
private static void registerResourcePack(AddPackFindersEvent event, Identifier id, boolean alwaysEnabled) { | ||
event.addRepositorySource(((profileAdder, factory) -> { | ||
IModFile file = ModList.get().getModFileById(id.getNamespace()).getFile(); | ||
try (PathPackResources pack = new PathPackResources(id.toString(), file.findResource("resourcepacks/"+id.getPath()))) { | ||
profileAdder.accept(new ResourcePackProfile(id.toString(), alwaysEnabled, () -> pack, Text.of(id.getNamespace()+"/"+id.getPath()), pack.parseMetadata(PackResourceMetadata.READER).getDescription().copy().append(" §7(built-in)"), ResourcePackCompatibility.COMPATIBLE, ResourcePackProfile.InsertionPosition.TOP, false, ResourcePackSource.PACK_SOURCE_BUILTIN, false)); | ||
} catch (IOException | NullPointerException e) {e.printStackTrace();} | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters