diff --git a/build.gradle b/build.gradle index bc68594c..34982931 100644 --- a/build.gradle +++ b/build.gradle @@ -105,6 +105,6 @@ dependencies { include(runtimeOnly "org.lwjgl:lwjgl-lmdb:$lwjglVersion:natives-linux") include(runtimeOnly "org.lwjgl:lwjgl-zstd:$lwjglVersion:natives-linux") - implementation 'org.rocksdb:rocksdbjni:8.10.0' - implementation 'redis.clients:jedis:5.1.0' + include(implementation 'org.rocksdb:rocksdbjni:8.10.0') + include(implementation 'redis.clients:jedis:5.1.0') } \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/core/DistanceTracker.java b/src/main/java/me/cortex/voxy/client/core/DistanceTracker.java index 5ca78b80..073eade7 100644 --- a/src/main/java/me/cortex/voxy/client/core/DistanceTracker.java +++ b/src/main/java/me/cortex/voxy/client/core/DistanceTracker.java @@ -87,7 +87,7 @@ public class DistanceTracker { public void init(int x, int z) { //Radius of chunks to enqueue - int SIZE = 40; + int SIZE = 64; //Insert highest LOD level for (int ox = -SIZE; ox <= SIZE; ox++) { for (int oz = -SIZE; oz <= SIZE; oz++) { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java index 0a1178b5..4946ea8e 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java @@ -10,6 +10,9 @@ import me.cortex.voxy.common.world.other.Mapper; import net.minecraft.block.FluidBlock; import org.lwjgl.system.MemoryUtil; +import java.lang.reflect.Array; +import java.util.Arrays; + public class RenderDataFactory { private final WorldEngine world; @@ -148,9 +151,13 @@ public class RenderDataFactory { //Need to access the other connecting section if (primary == 0) { if (!obtainedOppositeSection0) { - var connectedSection = this.world.acquire(section.lvl, section.x - aX, section.y - aY, section.z - aZ); - connectedSection.copyDataTo(this.connectedSectionCache); - connectedSection.release(); + var connectedSection = this.world.acquireIfExists(section.lvl, section.x - aX, section.y - aY, section.z - aZ); + if (connectedSection != null) { + connectedSection.copyDataTo(this.connectedSectionCache); + connectedSection.release(); + } else { + Arrays.fill(this.connectedSectionCache, 0); + } obtainedOppositeSection0 = true; } facingState = this.connectedSectionCache[WorldSection.getIndex(x*(1-aX)+(31*aX), y*(1-aY)+(31*aY), z*(1-aZ)+(31*aZ))]; @@ -165,9 +172,13 @@ public class RenderDataFactory { //Need to access the other connecting section if (primary == 31) { if (!obtainedOppositeSection31) { - var connectedSection = this.world.acquire(section.lvl, section.x + aX, section.y + aY, section.z + aZ); - connectedSection.copyDataTo(this.connectedSectionCache); - connectedSection.release(); + var connectedSection = this.world.acquireIfExists(section.lvl, section.x + aX, section.y + aY, section.z + aZ); + if (connectedSection != null) { + connectedSection.copyDataTo(this.connectedSectionCache); + connectedSection.release(); + } else { + Arrays.fill(this.connectedSectionCache, 0); + } obtainedOppositeSection31 = true; } facingState = this.connectedSectionCache[WorldSection.getIndex(x*(1-aX), y*(1-aY), z*(1-aZ))]; diff --git a/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java b/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java index 41b517f0..a06a57ce 100644 --- a/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java +++ b/src/main/java/me/cortex/voxy/common/world/ActiveSectionTracker.java @@ -49,8 +49,10 @@ public class ActiveSectionTracker { } if (status < 0) { - //TODO: Instead if throwing an exception do something better - throw new IllegalStateException("Unable to load section"); + //TODO: Instead if throwing an exception do something better, like attempting to regen + //throw new IllegalStateException("Unable to load section: "); + System.err.println("Unable to load section " + section.key + " setting to air"); + status = 1; } section.acquire(); holder.obj = section; diff --git a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java index 769c4119..95b7c1e0 100644 --- a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java +++ b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java @@ -67,7 +67,9 @@ public class SaveLoadSystem { } if (section.key != key) { - throw new IllegalStateException("Decompressed section not the same as requested. got: " + key + " expected: " + section.key); + //throw new IllegalStateException("Decompressed section not the same as requested. got: " + key + " expected: " + section.key); + System.err.println("Decompressed section not the same as requested. got: " + key + " expected: " + section.key); + return false; } for (int i = 0; i < section.data.length; i++) {