aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/lodmod/renderer/LODRenderer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/makamys/lodmod/renderer/LODRenderer.java')
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java19
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) {