From 00638dc06a0d39e4beed9e8cb99427fa33a88d6f Mon Sep 17 00:00:00 2001 From: plastoid501 Date: Fri, 30 Aug 2024 09:24:03 +0900 Subject: [PATCH] fix chunk border rendering + delete unnecessary rows --- .../iris/mixin/MixinChunkBorderRenderer.java | 36 +++++++++++++++++++ common/src/main/resources/mixins.iris.json | 1 + 2 files changed, 37 insertions(+) create mode 100644 common/src/main/java/net/irisshaders/iris/mixin/MixinChunkBorderRenderer.java diff --git a/common/src/main/java/net/irisshaders/iris/mixin/MixinChunkBorderRenderer.java b/common/src/main/java/net/irisshaders/iris/mixin/MixinChunkBorderRenderer.java new file mode 100644 index 0000000000..0b41e52abd --- /dev/null +++ b/common/src/main/java/net/irisshaders/iris/mixin/MixinChunkBorderRenderer.java @@ -0,0 +1,36 @@ +package net.irisshaders.iris.mixin; + +import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.renderer.debug.ChunkBorderRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Slice; + +@Mixin(ChunkBorderRenderer.class) +public class MixinChunkBorderRenderer { + @WrapWithCondition( + method = "render", + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;endVertex()V"), + slice = @Slice( + from = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack$Pose;pose()Lorg/joml/Matrix4f;"), + to = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/debug/ChunkBorderRenderer;CELL_BORDER:I", ordinal = 0) + ) + ) + private boolean isCameraChunk(VertexConsumer instance, @Local(ordinal = 0) int k, @Local(ordinal = 1) int l) { + return !((k == 0 || k == 16) && (l == 0 || l == 16)); + } + + @WrapWithCondition( + method = "render", + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;endVertex()V"), + slice = @Slice( + from = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getMinBuildHeight()I", ordinal = 1), + to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource;getBuffer(Lnet/minecraft/client/renderer/RenderType;)Lcom/mojang/blaze3d/vertex/VertexConsumer;", ordinal = 1) + ) + ) + private boolean isSubChunkBorder(VertexConsumer instance, @Local(ordinal = 0) int k) { + return k % 16 != 0; + } +} diff --git a/common/src/main/resources/mixins.iris.json b/common/src/main/resources/mixins.iris.json index 9cf26e2834..79ff9c87eb 100644 --- a/common/src/main/resources/mixins.iris.json +++ b/common/src/main/resources/mixins.iris.json @@ -17,6 +17,7 @@ "MixinBooleanState", "MixinByteBufferBuilder", "MixinChainedJsonException", + "MixinChunkBorderRenderer", "MixinClientLanguage", "MixinClientPacketListener", "MixinDebugScreenOverlay",