From 8c7d4c0cc562bd332bbcdec05b4a1f8143c67962 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Sat, 28 Mar 2020 20:49:55 -0400 Subject: [PATCH] Fix #377 - Added comments to help explain some of the logic of the Region/CuboidRegion filtering --- .../main/java/com/sk89q/worldedit/regions/CuboidRegion.java | 6 ++++-- .../src/main/java/com/sk89q/worldedit/regions/Region.java | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 8b328bb95..f54749b42 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -653,7 +653,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { int chunkZ = chunk.getZ(); block = block.initChunk(chunkX, chunkZ); - + //Chunk entry is an "interior chunk" in regards to the entire region, so filter the chunk whole instead of partially if ((minX + 15) >> 4 <= chunkX && (maxX - 15) >> 4 >= chunkX && (minZ + 15) >> 4 <= chunkZ && (maxZ - 15) >> 4 >= chunkZ) { filter(chunk, filter, block, get, set, minY, maxY, full); return; @@ -672,12 +672,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ, full); return; } + //If the yStart is not 0, the edit is smaller than the height of a ChunkSection, so filter individually and remove section as the minSection layer entry if (yStart != 0) { filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, 15, localMaxZ, full); minSection++; } + //If the yEnd is not 15, the edit is smaller than the height of a ChunkSection, so filter individually and remove section as the maxSection layer entry if (yEnd != 15) { - filter(chunk, filter, block, get, set, minSection, localMinX, 0, localMinZ, localMaxX, yEnd, localMaxZ, full); + filter(chunk, filter, block, get, set, maxSection, localMinX, 0, localMinZ, localMaxX, yEnd, localMaxZ, full); maxSection--; } for (int layer = minSection; layer <= maxSection; layer++) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index b2880913d..3fa0a57d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -219,12 +219,14 @@ public interface Region extends Iterable, Cloneable, IBatchProcess filter(chunk, filter, block, get, set, minSection, yStart, yEnd, full); return; } + //If the yStart is not 0, the edit is smaller than the height of a ChunkSection, so filter individually and remove section as the minSection layer entry if (yStart != 0) { filter(chunk, filter, block, get, set, minSection, yStart, 15, full); minSection++; } + //If the yEnd is not 15, the edit is smaller than the height of a ChunkSection, so filter individually and remove section as the maxSection layer entry if (yEnd != 15) { - filter(chunk, filter, block, get, set, minSection, 0, yEnd, full); + filter(chunk, filter, block, get, set, maxSection, 0, yEnd, full); maxSection--; } for (int layer = minSection; layer <= maxSection; layer++) {