From 5969d99db1753dd4b7ca6d04596487558a11529b Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 15 Jul 2023 14:41:05 +0100 Subject: [PATCH] minor changes --- .../core/extent/OncePerChunkExtent.java | 7 +++- .../core/math/LocalBlockVector2Set.java | 35 +++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/OncePerChunkExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/OncePerChunkExtent.java index cd2d68f9a..9869fede1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/OncePerChunkExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/OncePerChunkExtent.java @@ -20,7 +20,9 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; /** - * Extent/processor that runs a t + * Extent/processor that runs a task the first time a chunk GET is loaded + * + * @since TODO */ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatchProcessor { @@ -34,6 +36,9 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch * Create a new instance. * * @param extent the extent + * @param queue Queue to load chunk GET from if acting as extent not processor + * @param task Consumer task for the chunk GET + * @since TODO */ public OncePerChunkExtent(Extent extent, IQueueExtent queue, Consumer task) { super(extent); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVector2Set.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVector2Set.java index 7937f7813..bfc80ee91 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVector2Set.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVector2Set.java @@ -11,9 +11,11 @@ import java.util.Iterator; import java.util.Set; /** - * The LocalBlockVectorSet is a Memory and CPU optimized Set for storing BlockVectors which are all in a local region - * - All vectors must be in a 2048 * 512 * 2048 area centered around the first entry - * - This will use 8 bytes for every 64 BlockVectors (about 800x less than a HashSet) + * The LocalBlockVector2Set is a Memory and CPU optimized Set for storing BlockVector2s which are all in a local region + * - All vectors must be in a 65534 * 65534 area centered around the first entry + * - This will use 8 bytes for every 64 BlockVector2s (about 600x less than a HashSet) + * + * @since TODO */ public class LocalBlockVector2Set implements Set { @@ -22,8 +24,9 @@ public class LocalBlockVector2Set implements Set { private int offsetZ; /** - * New LocalBlockVectorSet that will set the offset x and z to the first value given. The y offset will default to 128 to - * allow -64 -> 320 world height. + * New LocalBlockVectorSet that will set the offset x and z to the first value given. + * + * @since TODO */ public LocalBlockVector2Set() { offsetX = offsetZ = Integer.MAX_VALUE; @@ -31,7 +34,7 @@ public class LocalBlockVector2Set implements Set { } /** - * New LocalBlockVectorSet with a given offset. Defaults y offset to 128. + * New LocalBlockVectorSet with a given offset. * * @param x x offset * @param z z offset @@ -71,10 +74,15 @@ public class LocalBlockVector2Set implements Set { } short sx = (short) (x - offsetX); short sz = (short) (z - offsetZ); - if (sx > 32767 || sx < -32768 || sz > 32767 || sz < -32768) { + if (sx > 32767 || sx < -32767 || sz > 32767 || sz < -32767) { return false; } - return set.get(MathMan.pairSearchCoords(sx, sz)); + try { + return set.get(MathMan.pairSearchCoords(sx, sz)); + } catch (IndexOutOfBoundsException e) { + System.out.println(x + " " + z + " " + sx + " " + sz); + throw e; + } } @Override @@ -125,8 +133,7 @@ public class LocalBlockVector2Set implements Set { } /** - * Set the offset applied to values when storing and reading to keep the values within -1024 to 1023. Uses default y offset - * of 128 to allow -64 -> 320 world height use. + * Set the offset applied to values when storing and reading to keep the values within -32767 to 32767. * * @param x x offset * @param z z offset @@ -226,7 +233,7 @@ public class LocalBlockVector2Set implements Set { } int relX = x - offsetX; int relZ = z - offsetZ; - return relX <= 32767 && relX >= -32768 && relZ <= 32727 && relZ >= -32768; + return relX <= 32767 && relX >= -32767 && relZ <= 32727 && relZ >= -32767; } /** @@ -243,9 +250,9 @@ public class LocalBlockVector2Set implements Set { } int relX = x - offsetX; int relZ = z - offsetZ; - if (relX > 32767 || relX < -32768 || relZ > 32767 || relZ < -32768) { + if (relX > 32767 || relX < -32767 || relZ > 32767 || relZ < -32767) { throw new UnsupportedOperationException( - "LocalBlockVector2Set can only contain vectors within 32768 blocks (cuboid) of the first entry. Attempted " + "to set block at " + x + ", " + z + ". With origin " + offsetX + " " + offsetZ); + "LocalBlockVector2Set can only contain vectors within 32767 blocks (cuboid) of the first entry. Attempted " + "to set block at " + x + ", " + z + ". With origin " + offsetX + " " + offsetZ); } int index = getIndex(x, z); if (set.get(index)) { @@ -285,7 +292,7 @@ public class LocalBlockVector2Set implements Set { public boolean remove(int x, int z) { int relX = x - offsetX; int relZ = z - offsetZ; - if (relX > 1023 || relX < -1024 || relZ > 1023 || relZ < -1024) { + if (relX > 32767 || relX < -32767 || relZ > 32767 || relZ < -32767) { return false; } int index = MathMan.pairSearchCoords((short) (x - offsetX), (short) (z - offsetZ));