diff options
author | makamys <makamys@outlook.com> | 2021-05-08 00:43:36 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-08 00:43:36 +0200 |
commit | d80373ad654a1f2d580a96e5e433712eaf045946 (patch) | |
tree | 3fc468dae13a3bfdd1a55a3b59b6fec401e43d35 /src | |
parent | e4fbba6e326619461e8e8bf2ebd20d2649aa2f41 (diff) | |
download | Neodymium-d80373ad654a1f2d580a96e5e433712eaf045946.tar.gz Neodymium-d80373ad654a1f2d580a96e5e433712eaf045946.tar.bz2 Neodymium-d80373ad654a1f2d580a96e5e433712eaf045946.zip |
less flicker
Diffstat (limited to 'src')
3 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java index 18f95a6..0f87216 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/lodmod/mixin/MixinRenderGlobal.java @@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import makamys.lodmod.LODMod; import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.WorldRenderer; @Mixin(RenderGlobal.class) abstract class MixinRenderGlobal { @@ -16,4 +17,13 @@ abstract class MixinRenderGlobal { thiz.renderAllRenderLists(p1, p2); } } + + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;getGLCallListForPass(I)I")) + public int redirectCallList(WorldRenderer thiz, int arg) { + int numba = thiz.getGLCallListForPass(arg); + if(numba != -1) { + LODMod.renderer.onWorldRendererFrustumChange(thiz, true); + } + return numba; + } } diff --git a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java index e7595d9..8146431 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java @@ -10,6 +10,7 @@ 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.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import makamys.lodmod.LODMod; import makamys.lodmod.ducks.ITessellator; @@ -36,6 +37,13 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Shadow public int posZ; + @Shadow + private boolean isInFrustum; + @Shadow + public boolean[] skipRenderPass; + @Shadow + private int glRenderList; + public List<ChunkMesh> chunkMeshes = new ArrayList<>(); @Redirect(method = "setPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;renderAABB(Lnet/minecraft/util/AxisAlignedBB;)V")) diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 23fb16b..f40c977 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -353,7 +353,14 @@ public class LODRenderer { public void onWorldRendererPost(WorldRenderer wr) { LODChunk lodChunk = getLODChunk(Math.floorDiv(wr.posX, 16), Math.floorDiv(wr.posZ, 16)); lodChunk.putChunkMeshes(Math.floorDiv(wr.posY, 16), ((IWorldRenderer)wr).getChunkMeshes()); - setVisible(lodChunk, false); + //setVisible(lodChunk, false); + } + + public void onWorldRendererFrustumChange(WorldRenderer wr, boolean inFrustum) { + if(inFrustum) { + LODChunk lodChunk = getLODChunk(Math.floorDiv(wr.posX, 16), Math.floorDiv(wr.posZ, 16)); + setVisible(lodChunk, false); + } } public void onDontDraw(WorldRenderer wr) { |