CullLeaves 3.1.0 - Update to 1.20

- Update to 1.20
- Attempt to fix random BufferUnderflowExceptions with Sodium once and for all
This commit is contained in:
Motschen
2023-07-12 12:36:33 +02:00
parent 74f2efbc88
commit 5177f4897f
3 changed files with 34 additions and 51 deletions

View File

@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
}
architectury {
@@ -26,7 +26,7 @@ subprojects {
// The following line declares the mojmap mappings, you may use other mappings as well
//mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
mappings "net.fabricmc:yarn:1.19.3+build.5:v2"
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2"
}
}

View File

@@ -11,62 +11,44 @@ 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.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 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);
@Unique private boolean doFix = false;
@Unique private ChunkCameraContext camera;
@Unique private ChunkRenderBounds bounds;
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;
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))
public ElementRange cullleaves$fixTransparentBlockFaceCulling(ChunkGraphicsState state, ModelQuadFacing facing) {
if (doFix) {
long indexOffset = state.getIndexSegment().getOffset();
int baseVertex = state.getVertexSegment().getOffset() / this.vertexFormat.getStride();
if (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);
}
@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);
}
}
return state.getModelPart(ModelQuadFacing.UNASSIGNED);
}
}

View File

@@ -1,20 +1,21 @@
org.gradle.jvmargs=-Xmx4096M
minecraft_version=1.19.3
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
enabled_platforms=quilt,fabric,forge
archives_base_name=cullleaves
mod_version=3.0.3
mod_version=3.1.0
maven_group=eu.midnightdust
architectury_version=6.2.43
midnightlib_version=1.1.0
sodium_version=mc1.19.3-0.4.9
midnightlib_version=1.4.1
sodium_version=mc1.20-0.4.10
fabric_loader_version=0.14.14
fabric_api_version=0.73.2+1.19.3
fabric_loader_version=0.14.21
fabric_api_version=0.85.0+1.20.1
forge_version=1.19.3-44.1.16
forge_version=1.20.1-47.1.0
quilt_loader_version=0.18.1-beta.27
quilt_fabric_api_version=5.0.0-beta.4+0.73.0-1.19.3
quilt_loader_version=0.18.9
quilt_fabric_api_version=7.0.6+0.85.0-1.20.1