From 4a4f5bcc7411fd83946078cc8f71dd9facb67f7e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 21 Dec 2019 05:20:17 +0000 Subject: [PATCH] Fix #288 sphere min/max y --- .../java/com/sk89q/worldedit/EditSession.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 4d5f091a4..bd504fab7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1928,6 +1928,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final int ceilRadiusY = (int) Math.ceil(radiusY); final int ceilRadiusZ = (int) Math.ceil(radiusZ); + int yy; + double nextXn = invRadiusX; forX: for (int x = 0; x <= ceilRadiusX; ++x) { final double xn = nextXn; @@ -1962,19 +1964,21 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { continue; } } - - this.setBlock(px + x, py + y, pz + z, block); - if (x != 0) this.setBlock(px - x, py + y, pz + z, block); - if (z != 0) { - this.setBlock(px + x, py + y, pz - z, block); - if (x != 0) this.setBlock(px - x, py + y, pz - z, block); - } - if (y != 0) { - this.setBlock(px + x, py - y, pz + z, block); - if (x != 0) this.setBlock(px - x, py - y, pz + z, block); + yy = py + y; + if (yy <= maxY) { + this.setBlock(px + x, py + y, pz + z, block); + if (x != 0) this.setBlock(px - x, py + y, pz + z, block); if (z != 0) { - this.setBlock(px + x, py - y, pz - z, block); - if (x != 0) this.setBlock(px - x, py - y, pz - z, block); + this.setBlock(px + x, py + y, pz - z, block); + if (x != 0) this.setBlock(px - x, py + y, pz - z, block); + } + } + if (y != 0 && (yy = py - y) >= 0) { + this.setBlock(px + x, yy, pz + z, block); + if (x != 0) this.setBlock(px - x, yy, pz + z, block); + if (z != 0) { + this.setBlock(px + x, yy, pz - z, block); + if (x != 0) this.setBlock(px - x, yy, pz - z, block); } } }