diff options
author | makamys <makamys@outlook.com> | 2022-06-30 11:46:32 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-30 11:47:20 +0200 |
commit | 965636d583a91c3420ec69b81c47b5b961eeb7a7 (patch) | |
tree | a0855955428668e32a83d40e419b8d70b249f0d1 /src | |
parent | 342ab04daf097aded45de402db73783fcc888c80 (diff) | |
download | Neodymium-965636d583a91c3420ec69b81c47b5b961eeb7a7.tar.gz Neodymium-965636d583a91c3420ec69b81c47b5b961eeb7a7.tar.bz2 Neodymium-965636d583a91c3420ec69b81c47b5b961eeb7a7.zip |
Fix meshes not disappearing properly when emptied of blocks
Diffstat (limited to 'src')
3 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index d744409..32b27a9 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -36,8 +36,18 @@ abstract class MixinWorldRenderer implements IWorldRenderer { private List<ChunkMesh> nd$chunkMeshes; - @Inject(method = {"updateRenderer", "updateRendererSort"}, at = @At(value = "HEAD")) + @Inject(method = {"updateRenderer"}, at = @At(value = "HEAD")) private void preUpdateRenderer(CallbackInfo ci) { + preUpdateRenderer(false); + } + + @Inject(method = {"updateRendererSort"}, at = @At(value = "HEAD")) + private void preUpdateRendererSort(CallbackInfo ci) { + preUpdateRenderer(true); + } + + @Unique + private void preUpdateRenderer(boolean sort) { saveDrawnStatus(); if(Neodymium.isActive()) { @@ -49,13 +59,23 @@ abstract class MixinWorldRenderer implements IWorldRenderer { } } - @Inject(method = {"updateRenderer", "updateRendererSort"}, at = @At(value = "RETURN")) + @Inject(method = {"updateRenderer"}, at = @At(value = "RETURN")) private void postUpdateRenderer(CallbackInfo ci) { + postUpdateRenderer(false); + } + + @Inject(method = {"updateRendererSort"}, at = @At(value = "RETURN")) + private void postUpdateRendererSort(CallbackInfo ci) { + postUpdateRenderer(true); + } + + @Unique + private void postUpdateRenderer(boolean sort) { notifyIfDrawnStatusChanged(); if(Neodymium.isActive()) { if(nd$chunkMeshes != null) { - Neodymium.renderer.onWorldRendererPost(WorldRenderer.class.cast(this)); + Neodymium.renderer.onWorldRendererPost(WorldRenderer.class.cast(this), sort); Collections.fill(nd$chunkMeshes, null); } } diff --git a/src/main/java/makamys/neodymium/renderer/NeoChunk.java b/src/main/java/makamys/neodymium/renderer/NeoChunk.java index 305b84c..3798845 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoChunk.java +++ b/src/main/java/makamys/neodymium/renderer/NeoChunk.java @@ -35,11 +35,11 @@ public class NeoChunk { return Math.pow(entity.posX - x * 16, 2) + Math.pow(entity.posZ - z * 16, 2); } - public void putChunkMeshes(int cy, List<ChunkMesh> newChunkMeshes) { + public void putChunkMeshes(int cy, List<ChunkMesh> newChunkMeshes, boolean addOnly) { for(int i = 0; i < 2; i++) { ChunkMesh newChunkMesh = newChunkMeshes.size() > i ? newChunkMeshes.get(i) : null; - if(newChunkMesh != null) { + if(!addOnly || newChunkMesh != null) { if(chunkMeshes[cy * 2 + i] != null) { if(newChunkMesh != null) { // ??? why is this needed? diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 7844d24..6a1c1e9 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -486,7 +486,7 @@ public class NeoRenderer { neoChunkChanged(neoChunk); } - public void onWorldRendererPost(WorldRenderer wr) { + public void onWorldRendererPost(WorldRenderer wr, boolean sort) { int x = Math.floorDiv(wr.posX, 16); int y = Math.floorDiv(wr.posY, 16); int z = Math.floorDiv(wr.posZ, 16); @@ -494,7 +494,7 @@ public class NeoRenderer { if(Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(x, z).isChunkLoaded) { NeoChunk neoChunk = getNeoChunk(x, z); neoChunk.isSectionVisible[y] = ((IWorldRenderer)wr).isDrawn(); - neoChunk.putChunkMeshes(y, ((IWorldRenderer)wr).getChunkMeshes()); + neoChunk.putChunkMeshes(y, ((IWorldRenderer)wr).getChunkMeshes(), sort); } } |