From ebc38a62ad6470d62b88795c57c60b3dbb3282bf Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 26 Aug 2021 16:44:49 +0100 Subject: [PATCH] Should fix #1237 and should fix #1236 --- .../main/java/com/sk89q/worldedit/regions/CuboidRegion.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 92ddcc65c..801be09dd 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 @@ -752,7 +752,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return set; } if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) { - trimY(set, minY, maxY); + if (minY > set.getMinSectionIndex() << 4 || maxY < (set.getMaxSectionIndex() << 4) + 15) { + trimY(set, minY, maxY); + } final int lowerX = Math.max(0, minX - bx); final int upperX = Math.min(15, 15 + maxX - tx); @@ -770,7 +772,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { char[] arr = set.load(layer); if (trimX || trimZ) { int indexY = 0; - for (int y = getWorldMinY(); y < 16; y++, indexY += getWorldMaxY()) { + for (int y = 0; y < 16; y++, indexY += 256) { // For each y layer within a chunk section int index; if (trimZ) { index = indexY;