mirror of
https://github.com/TeamMidnightDust/CullLeaves.git
synced 2025-12-15 14:15:08 +01:00
CullLeaves 3.2.0 - Mangrove Root Culling & Sodium fix
- Added an option to cull Mangrove Roots (closes #47) - Fixed incompatibility with Sodium by removing a now obsolete feature - Add German translation by myself
This commit is contained in:
@@ -5,6 +5,6 @@ import eu.midnightdust.lib.config.MidnightConfig;
|
||||
public class CullLeavesConfig extends MidnightConfig {
|
||||
@Entry // Enable/Disable the mod. Requires Chunk Reload (F3 + A).
|
||||
public static boolean enabled = true;
|
||||
@Entry // Fixes resourcepacks utilizing leaf culling flickering when using Sodium
|
||||
public static boolean sodiumBlockFaceCullingFix = true;
|
||||
@Entry // Enable/Disable culling on Mangrove Roots.
|
||||
public static boolean cullRoots = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.midnightdust.cullleaves.mixin;
|
||||
|
||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(value = MangroveRootsBlock.class, priority = 1900)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public abstract class MixinMangroveRootsBlock extends Block {
|
||||
|
||||
public MixinMangroveRootsBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
||||
if (CullLeavesConfig.cullRoots) {
|
||||
return neighborState.getBlock() instanceof MangroveRootsBlock;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
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.render.chunk.*;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderBounds;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import me.jellysquid.mods.sodium.client.render.vertex.type.ChunkVertexType;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = RegionChunkRenderer.class, remap = false, priority = 1100)
|
||||
public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer {
|
||||
@Shadow @Final private boolean isBlockFaceCullingEnabled;
|
||||
@Shadow protected abstract void addDrawCall(ElementRange part, long baseIndexPointer, int baseVertexIndex);
|
||||
|
||||
public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) {
|
||||
super(device, vertexType);
|
||||
}
|
||||
|
||||
@Inject(method = "buildDrawBatches", locals = LocalCapture.CAPTURE_FAILSOFT, 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 void cullleaves$fixTransparentBlockFaceCulling(List<RenderSection> sections, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfoReturnable<Boolean> cir, Iterator var4, RenderSection render, ChunkGraphicsState state, ChunkRenderBounds bounds, long indexOffset, int baseVertex) {
|
||||
if (pass.getAlphaCutoff() != 0 && CullLeavesConfig.enabled && CullLeavesConfig.sodiumBlockFaceCullingFix && this.isBlockFaceCullingEnabled) {
|
||||
if (camera.posY <= bounds.y1) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.UP), indexOffset, baseVertex);
|
||||
}
|
||||
if (camera.posY >= bounds.y2) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.DOWN), indexOffset, baseVertex);
|
||||
}
|
||||
if (camera.posX <= bounds.x1) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.EAST), indexOffset, baseVertex);
|
||||
}
|
||||
if (camera.posX >= bounds.x2) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.WEST), indexOffset, baseVertex);
|
||||
}
|
||||
if (camera.posZ <= bounds.z1) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.SOUTH), indexOffset, baseVertex);
|
||||
}
|
||||
if (camera.posZ >= bounds.z2) {
|
||||
this.addDrawCall(state.getModelPart(ModelQuadFacing.NORTH), indexOffset, baseVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,17 @@ public class MixinSodiumGameOptionPages {
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(Text.translatable("cullleaves.midnightconfig.cullRoots"))
|
||||
.setTooltip(Text.translatable("cullleaves.midnightconfig.cullRoots.tooltip.sodium"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> {
|
||||
CullLeavesConfig.cullRoots = value;
|
||||
CullLeavesConfig.write("cullleaves");
|
||||
}, opts -> CullLeavesConfig.cullRoots)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
|
||||
9
common/src/main/resources/assets/cullleaves/lang/de_de.json
Executable file
9
common/src/main/resources/assets/cullleaves/lang/de_de.json
Executable file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"cullleaves.midnightconfig.title":"Cull Leaves Konfiguration",
|
||||
"cullleaves.midnightconfig.enabled.tooltip":"Aktiviert Culling bei Blättern, was zu besserer Performance führt.\n§cNach dem Ändern dieser Option müssen alle Chunks neugeladen werden (F3 + A)",
|
||||
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Aktiviert Culling bei Blättern, was zu besserer Performance führt.",
|
||||
"cullleaves.midnightconfig.enabled":"Aktiviere Culling von Blättern",
|
||||
"cullleaves.midnightconfig.cullRoots.tooltip":"Aktiviert Culling von Mangrovenwurzeln.\n§cNach dem Ändern dieser Option müssen alle Chunks neugeladen werden (F3 + A)",
|
||||
"cullleaves.midnightconfig.cullRoots.tooltip.sodium":"Aktiviert Culling von Mangrovenwurzeln.",
|
||||
"cullleaves.midnightconfig.cullRoots":"Culling von Mangrovenwurzeln"
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"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"
|
||||
"cullleaves.midnightconfig.cullRoots.tooltip":"Enables culling for mangrove roots.\n§cAfter changing this setting you have to reload all chunks (F3 + A)",
|
||||
"cullleaves.midnightconfig.cullRoots.tooltip.sodium":"Enables culling for mangrove roots.",
|
||||
"cullleaves.midnightconfig.cullRoots":"Enable Mangrove Root Culling"
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
"MixinLeavesBlock",
|
||||
"MixinRegionChunkRenderer",
|
||||
"MixinMangroveRootsBlock",
|
||||
"MixinSodiumGameOptionPages"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
Reference in New Issue
Block a user