From 562b0a8da2447df5366f59f9dc47c6db9f74e873 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 19 May 2023 07:20:18 -0500 Subject: [PATCH] Fix worldGenQueue outOfBoundExceptions when moving quickly Not a perfect solution, long term a fix should be done in the tree, but that can be done another time --- .../lod/core/generation/WorldGenerationQueue.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java index a0c36c74c..f0d9a1fe4 100644 --- a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java @@ -248,9 +248,20 @@ public class WorldGenerationQueue implements Closeable Iterator> nodeIterator = this.waitingTaskQuadTree.nodeIterator(); while (nodeIterator.hasNext()) { - WorldGenTask newGenTask = nodeIterator.next().value; + QuadNode taskNode = nodeIterator.next(); + WorldGenTask newGenTask = taskNode.value; + DhSectionPos taskSectionPos = taskNode.sectionPos; + if (newGenTask != null) // TODO add an option to skip leaves with null values and potentially auto-prune them { + // TODO this isn't a long term fix, in the long term the tree should automatically remove out of bound nodes when moved + if (!this.waitingTaskQuadTree.isSectionPosInBounds(taskSectionPos)) + { + // skip and remove out-of-bound tasks + taskNode.value = null; + continue; + } + // use chebyShev distance in order to generate in rings around the target pos (also because it is a fast distance calculation) int chebDistToTargetPos = newGenTask.pos.getCenterBlockPos().toPos2D().chebyshevDist(targetPos.toPos2D());