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
This commit is contained in:
James Seibel
2023-05-19 07:20:18 -05:00
parent 95db633e09
commit 562b0a8da2
@@ -248,9 +248,20 @@ public class WorldGenerationQueue implements Closeable
Iterator<QuadNode<WorldGenTask>> nodeIterator = this.waitingTaskQuadTree.nodeIterator();
while (nodeIterator.hasNext())
{
WorldGenTask newGenTask = nodeIterator.next().value;
QuadNode<WorldGenTask> 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());