Skip to content

Commit a9819ca

Browse files
committed
Fix negative height cones.
Despite the description/doc stating that negative heights would generate inverted cones, this wasn't actually implemented.
1 parent cd2ddef commit a9819ca

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,9 +1832,10 @@ public int makeCone(BlockVector3 pos, Pattern block, double radiusX, double radi
18321832
final double radiusXPow = Math.pow(radiusX, 2);
18331833
final double radiusZPow = Math.pow(radiusZ, 2);
18341834
final double heightPow = Math.pow(height, 2);
1835+
final int layers = Math.abs(height);
18351836

1836-
for (int y = 0; y < height; ++y) {
1837-
double ySquaredMinusHeightOverHeightSquared = Math.pow(y - height, 2) / heightPow;
1837+
for (int y = 0; y < layers; ++y) {
1838+
double ySquaredMinusHeightOverHeightSquared = Math.pow(y - layers, 2) / heightPow;
18381839

18391840
forX:
18401841
for (int x = 0; x <= ceilRadiusX; ++x) {
@@ -1856,25 +1857,26 @@ public int makeCone(BlockVector3 pos, Pattern block, double radiusX, double radi
18561857
double xNext = Math.pow(x + thickness, 2) / radiusXPow
18571858
+ zSquaredOverRadiusZ - ySquaredMinusHeightOverHeightSquared;
18581859
double yNext = xSquaredOverRadiusX + zSquaredOverRadiusZ
1859-
- Math.pow(y + thickness - height, 2) / heightPow;
1860+
- Math.pow(y + thickness - layers, 2) / heightPow;
18601861
double zNext = xSquaredOverRadiusX + Math.pow(z + thickness, 2)
18611862
/ radiusZPow - ySquaredMinusHeightOverHeightSquared;
1862-
if (xNext <= 0 && zNext <= 0 && (yNext <= 0 && y + thickness != height)) {
1863+
if (xNext <= 0 && zNext <= 0 && (yNext <= 0 && y + thickness != layers)) {
18631864
continue;
18641865
}
18651866
}
18661867

18671868
if (distanceFromOriginMinusHeightSquared <= 0) {
1868-
if (setBlock(pos.add(x, y, z), block)) {
1869+
int yOffset = height < 0 ? -y : y;
1870+
if (setBlock(pos.add(x, yOffset, z), block)) {
18691871
++affected;
18701872
}
1871-
if (setBlock(pos.add(-x, y, z), block)) {
1873+
if (setBlock(pos.add(-x, yOffset, z), block)) {
18721874
++affected;
18731875
}
1874-
if (setBlock(pos.add(x, y, -z), block)) {
1876+
if (setBlock(pos.add(x, yOffset, -z), block)) {
18751877
++affected;
18761878
}
1877-
if (setBlock(pos.add(-x, y, -z), block)) {
1879+
if (setBlock(pos.add(-x, yOffset, -z), block)) {
18781880
++affected;
18791881
}
18801882
}

0 commit comments

Comments
 (0)