diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/AsyncNodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/AsyncNodeManager.java index 212548d1..e9c92a9f 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/AsyncNodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/AsyncNodeManager.java @@ -648,8 +648,12 @@ public class AsyncNodeManager { public void addTopLevel(long section) {//Only called from render thread if (!this.running) throw new IllegalStateException("Not running"); long stamp = this.tlnLock.writeLock(); - int state = this.tlnAdd.add(section)?1:0; - state -= this.tlnRem.remove(section)?1:0; + int state = 0; + if (!this.tlnRem.remove(section)) { + state += this.tlnAdd.add(section)?1:0; + } else { + state -= 1; + } if (state != 0) { if (this.workCounter.getAndAdd(state) == 0) { LockSupport.unpark(this.thread); @@ -661,8 +665,12 @@ public class AsyncNodeManager { public void removeTopLevel(long section) {//Only called from render thread if (!this.running) throw new IllegalStateException("Not running"); long stamp = this.tlnLock.writeLock(); - int state = this.tlnRem.add(section)?1:0; - state -= this.tlnAdd.remove(section)?1:0; + int state = 0; + if (!this.tlnAdd.remove(section)) { + state += this.tlnRem.add(section)?1:0; + } else { + state -= 1; + } if (state != 0) { if (this.workCounter.getAndAdd(state) == 0) { LockSupport.unpark(this.thread); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java index 9f80ea87..1e560753 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java @@ -162,7 +162,7 @@ public class NodeManager { public void removeTopLevelNode(long pos) { if (!this.topLevelNodes.remove(pos)) { - throw new IllegalStateException("Position not in top level map"); + throw new IllegalStateException("Position not in top level map: " + WorldEngine.pprintPos(pos)); } int nodeId = this.activeSectionMap.get(pos); if (nodeId == -1) {