From c5ff743c9e763eb14920b1ab4b197c3dccad422e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 9 Feb 2022 14:23:50 +0000 Subject: [PATCH] y index utility method in ChunknQueueCoordinator --- .../plotsquared/core/queue/ChunkQueueCoordinator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java index ee58dabfc..ad68de264 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java @@ -101,7 +101,7 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { } private void storeCache(final int x, final int y, final int z, final @NonNull BlockState id) { - int yIndex = y - weWorld.getMinY(); + int yIndex = getYIndex(y); BlockState[][] resultY = result[yIndex]; if (resultY == null) { result[yIndex] = resultY = new BlockState[length][]; @@ -114,7 +114,7 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { } private void storeCacheBiome(final int x, final int y, final int z, final @NonNull BiomeType id) { - int yIndex = y - weWorld.getMinY(); + int yIndex = getYIndex(y); BiomeType[][] resultY = biomeResult[yIndex]; if (resultY == null) { biomeResult[yIndex] = resultY = new BiomeType[length][]; @@ -134,7 +134,7 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { @Override public @Nullable BlockState getBlock(int x, int y, int z) { - BlockState[][] blocksY = result[y - weWorld.getMinY()]; + BlockState[][] blocksY = result[getYIndex(y)]; if (blocksY != null) { BlockState[] blocksYZ = blocksY[z]; if (blocksYZ != null) { @@ -159,4 +159,8 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { return Location.at(getWorld().getName(), bot.getX(), bot.getY(), bot.getZ()); } + private int getYIndex(int y) { + return y - weWorld.getMinY(); + } + }