diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinChunkBuilder_BuiltChunk.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinChunkBuilder_BuiltChunk.java index 6bd7bbcfb..dbd4d4f52 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinChunkBuilder_BuiltChunk.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinChunkBuilder_BuiltChunk.java @@ -19,4 +19,13 @@ private void allowEdgeChunksToRender(long l, CallbackInfoReturnable cir cir.setReturnValue(true); } } + + @Inject(method = "shouldBuild", at = @At("HEAD"), cancellable = true) + private void shouldBuild(CallbackInfoReturnable cir) + { + if (FeatureToggle.TWEAK_RENDER_EDGE_CHUNKS.getBooleanValue()) + { + cir.setReturnValue(true); + } + } } diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinFrustum.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinFrustum.java new file mode 100644 index 000000000..9fbcd2fdd --- /dev/null +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinFrustum.java @@ -0,0 +1,20 @@ +package fi.dy.masa.tweakeroo.mixin; + +import fi.dy.masa.tweakeroo.config.FeatureToggle; +import net.minecraft.client.render.Frustum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Frustum.class) +public class MixinFrustum { + @Inject(method = "isVisible(DDDDDD)Z", at = @At("HEAD"), cancellable = true) + private void shouldBuild(CallbackInfoReturnable cir) + { + if (FeatureToggle.TWEAK_RENDER_EDGE_CHUNKS.getBooleanValue()) + { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorldRenderer.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorldRenderer.java index 136c64332..0df267e21 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorldRenderer.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorldRenderer.java @@ -1,5 +1,6 @@ package fi.dy.masa.tweakeroo.mixin; +import net.minecraft.client.option.GameOptions; import org.joml.Matrix4f; import org.objectweb.asm.Opcodes; @@ -110,4 +111,24 @@ private void rebuildChunksAroundCamera2( // Could send this to ServuX in the future } } + + @Redirect( + method = "*", + require = 0, + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getClampedViewDistance()I") + ) + private int getViewDistance(GameOptions options) + { + if (FeatureToggle.TWEAK_RENDER_EDGE_CHUNKS.getBooleanValue()) + { + // In this way, the edge chunk is always rendered even if: + // + the chunks are outside the view distance + // + the camera is outside the view distance + return options.getClampedViewDistance() + 8; + } + else + { + return options.getClampedViewDistance(); + } + } } diff --git a/src/main/resources/mixins.tweakeroo.json b/src/main/resources/mixins.tweakeroo.json index 3ed410899..99241df3f 100644 --- a/src/main/resources/mixins.tweakeroo.json +++ b/src/main/resources/mixins.tweakeroo.json @@ -45,6 +45,7 @@ "MixinEntityRenderDispatcher", "MixinExplosionEmitterParticle", "MixinFillCommand", + "MixinFrustum", "MixinGameRenderer", "MixinGameRenderer_ViewBob", "MixinHeldItemRenderer",