diff options
author | makamys <makamys@outlook.com> | 2021-05-09 03:56:44 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-09 03:57:27 +0200 |
commit | fea376e79df165e8b3019ae17ffd934569f64b7a (patch) | |
tree | 8e4afd367bcaddd16e0771c17eb932c1834610ef /src/main/java/makamys/lodmod | |
parent | ccb69814e0c5747efe84c4dc6a40bfe076ecf0c0 (diff) | |
download | Neodymium-fea376e79df165e8b3019ae17ffd934569f64b7a.tar.gz Neodymium-fea376e79df165e8b3019ae17ffd934569f64b7a.tar.bz2 Neodymium-fea376e79df165e8b3019ae17ffd934569f64b7a.zip |
Don't save the model of chunks on the edge of the loaded world
Fixes ocean water derpiness
Diffstat (limited to 'src/main/java/makamys/lodmod')
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 7f5bbdb..eb4dc45 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -363,8 +363,23 @@ 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()); + int x = Math.floorDiv(wr.posX, 16); + int z = Math.floorDiv(wr.posZ, 16); + LODChunk lodChunk = getLODChunk(x, z); + if(areSurroundingChunksLoaded(x, z, wr.worldObj)) { + lodChunk.putChunkMeshes(Math.floorDiv(wr.posY, 16), ((IWorldRenderer)wr).getChunkMeshes()); + } + } + + public boolean areSurroundingChunksLoaded(int x, int z, World world) { + for(int dx = -1; dx <= 1; dx++) { + for(int dz = -1; dz <= 1; dz++) { + if(!world.getChunkFromChunkCoords(x + dx, z + dz).isChunkLoaded) { + return false; + } + } + } + return true; } public void onWorldRendererRender(WorldRenderer wr) { |