Skip to content

Commit

Permalink
fix: tweakRenderEdgeChunks (#81)
Browse files Browse the repository at this point in the history
* fix: tweakRenderEdgeChunks

* fix

* fix: disabling frustum is still necessary
  • Loading branch information
zly2006 authored Dec 7, 2024
1 parent 583f795 commit 87ecd46
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ private void allowEdgeChunksToRender(BlockPos pos, CallbackInfoReturnable<Boolea
cir.setReturnValue(true);
}
}

@Inject(method = "shouldBuild", at = @At("HEAD"), cancellable = true)
private void shouldBuild(CallbackInfoReturnable<Boolean> cir)
{
if (FeatureToggle.TWEAK_RENDER_EDGE_CHUNKS.getBooleanValue())
{
cir.setReturnValue(true);
}
}
}
20 changes: 20 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/mixin/MixinFrustum.java
Original file line number Diff line number Diff line change
@@ -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<Boolean> cir)
{
if (FeatureToggle.TWEAK_RENDER_EDGE_CHUNKS.getBooleanValue())
{
cir.setReturnValue(true);
}
}
}
21 changes: 21 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorldRenderer.java
Original file line number Diff line number Diff line change
@@ -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;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -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();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.tweakeroo.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"MixinEntityRenderDispatcher",
"MixinExplosion",
"MixinFillCommand",
"MixinFrustum",
"MixinGameRenderer",
"MixinGameRenderer_ViewBob",
"MixinHeldItemRenderer",
Expand Down

0 comments on commit 87ecd46

Please sign in to comment.