mirror of
https://github.com/TeamMidnightDust/CullLeaves.git
synced 2025-12-17 14:45:09 +01:00
@@ -6,6 +6,7 @@ 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.quad.properties.ModelQuadFacing;
|
||||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
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.*;
|
||||||
|
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.chunk.passes.BlockRenderPass;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -18,11 +19,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(value = RegionChunkRenderer.class, remap = false)
|
@Mixin(value = RegionChunkRenderer.class, remap = false, priority = 1100)
|
||||||
public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer {
|
public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer {
|
||||||
@Shadow @Final private boolean isBlockFaceCullingEnabled;
|
@Shadow @Final private boolean isBlockFaceCullingEnabled;
|
||||||
@Shadow protected abstract void addDrawCall(ElementRange part, long baseIndexPointer, int baseVertexIndex);
|
@Shadow protected abstract void addDrawCall(ElementRange part, long baseIndexPointer, int baseVertexIndex);
|
||||||
@Unique private boolean doFix = false;
|
@Unique private boolean doFix = false;
|
||||||
|
@Unique private ChunkCameraContext camera;
|
||||||
|
@Unique private ChunkRenderBounds bounds;
|
||||||
|
|
||||||
public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) {
|
public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) {
|
||||||
super(device, vertexType);
|
super(device, vertexType);
|
||||||
@@ -31,14 +34,37 @@ public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer {
|
|||||||
@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))
|
@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) {
|
public void cullleaves$shouldApplyTransparentBlockFaceCullingFix(List<RenderSection> sections, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfoReturnable<Boolean> cir) {
|
||||||
doFix = pass.getAlphaCutoff() != 0 && CullLeavesConfig.enabled && CullLeavesConfig.sodiumBlockFaceCullingFix && this.isBlockFaceCullingEnabled;
|
doFix = pass.getAlphaCutoff() != 0 && CullLeavesConfig.enabled && CullLeavesConfig.sodiumBlockFaceCullingFix && this.isBlockFaceCullingEnabled;
|
||||||
|
this.camera = camera;
|
||||||
|
}
|
||||||
|
@Redirect(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 ChunkRenderBounds cullleaves$getChunkRenderBounds(RenderSection instance) {
|
||||||
|
bounds = instance.getBounds();
|
||||||
|
return bounds;
|
||||||
}
|
}
|
||||||
@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))
|
@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) {
|
public ElementRange cullleaves$fixTransparentBlockFaceCulling(ChunkGraphicsState state, ModelQuadFacing facing) {
|
||||||
if (doFix) {
|
if (doFix) {
|
||||||
long indexOffset = state.getIndexSegment().getOffset();
|
long indexOffset = state.getIndexSegment().getOffset();
|
||||||
int baseVertex = state.getVertexSegment().getOffset() / this.vertexFormat.getStride();
|
int baseVertex = state.getVertexSegment().getOffset() / this.vertexFormat.getStride();
|
||||||
for (ModelQuadFacing direction : ModelQuadFacing.DIRECTIONS) {
|
if (this.isBlockFaceCullingEnabled) {
|
||||||
this.addDrawCall(state.getModelPart(direction), indexOffset, baseVertex);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return state.getModelPart(ModelQuadFacing.UNASSIGNED);
|
return state.getModelPart(ModelQuadFacing.UNASSIGNED);
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ side = "CLIENT"
|
|||||||
modId = "midnightlib"
|
modId = "midnightlib"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.0.0,)"
|
versionRange = "[1.0.0,)"
|
||||||
ordering = "NONE"
|
ordering = "BEFORE"
|
||||||
side = "CLIENT"
|
side = "CLIENT"
|
||||||
@@ -4,7 +4,7 @@ minecraft_version=1.19.2
|
|||||||
enabled_platforms=quilt,fabric,forge
|
enabled_platforms=quilt,fabric,forge
|
||||||
|
|
||||||
archives_base_name=cullleaves
|
archives_base_name=cullleaves
|
||||||
mod_version=3.0.0
|
mod_version=3.0.1
|
||||||
maven_group=eu.midnightdust
|
maven_group=eu.midnightdust
|
||||||
|
|
||||||
architectury_version=6.2.43
|
architectury_version=6.2.43
|
||||||
|
|||||||
Reference in New Issue
Block a user