From 3ad6577be6afce4ffb8c61d0872a3cb98b605ead Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 17 Oct 2010 17:39:20 -0700 Subject: [PATCH] Changed //cyl and //hcyl to respect boundaries. --- src/EditSession.java | 26 +++++++++++++ src/WorldEdit.java | 4 +- src/com/sk89q/worldedit/Vector.java | 60 +++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/EditSession.java b/src/EditSession.java index e222d5bb6..a5a7361f0 100644 --- a/src/EditSession.java +++ b/src/EditSession.java @@ -887,6 +887,19 @@ public class EditSession { int d = (5 - radius * 4) / 4; int affected = 0; + if (height == 0) { + return 0; + } else if (height < 0) { + height = -height; + pos = pos.subtract(0, height, 0); + } + + if (pos.getBlockY() - height - 1 < 0) { + height = pos.getBlockY() + 1; + } else if (pos.getBlockY() + height - 1 > 127) { + height = 127 - pos.getBlockY() + 1; + } + affected += makeHCylinderPoints(pos, x, z, height, block); while (x < z) { @@ -961,6 +974,19 @@ public class EditSession { int d = (5 - radius * 4) / 4; int affected = 0; + if (height == 0) { + return 0; + } else if (height < 0) { + height = -height; + pos = pos.subtract(0, height, 0); + } + + if (pos.getBlockY() - height - 1 < 0) { + height = pos.getBlockY() + 1; + } else if (pos.getBlockY() + height - 1 > 127) { + height = 127 - pos.getBlockY() + 1; + } + affected += makeCylinderPoints(pos, x, z, height, block); while (x < z) { diff --git a/src/WorldEdit.java b/src/WorldEdit.java index 06dc044dc..565a738ad 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -411,7 +411,7 @@ public class WorldEdit { checkArgs(split, 2, 3, split[0]); BaseBlock block = getBlock(split[1]); int radius = Math.max(1, Integer.parseInt(split[2])); - int height = split.length > 3 ? Math.max(1, Integer.parseInt(split[3])) : 1; + int height = split.length > 3 ? Integer.parseInt(split[3]) : 1; Vector pos = session.getPlacementPosition(player); int affected = editSession.makeHollowCylinder(pos, block, radius, height); @@ -424,7 +424,7 @@ public class WorldEdit { checkArgs(split, 2, 3, split[0]); BaseBlock block = getBlock(split[1]); int radius = Math.max(1, Integer.parseInt(split[2])); - int height = split.length > 3 ? Math.max(1, Integer.parseInt(split[3])) : 1; + int height = split.length > 3 ? Integer.parseInt(split[3]) : 1; Vector pos = session.getPlacementPosition(player); int affected = editSession.makeCylinder(pos, block, radius, height); diff --git a/src/com/sk89q/worldedit/Vector.java b/src/com/sk89q/worldedit/Vector.java index 1a92b1a43..925327151 100644 --- a/src/com/sk89q/worldedit/Vector.java +++ b/src/com/sk89q/worldedit/Vector.java @@ -99,6 +99,26 @@ public class Vector { return (int)Math.round(x); } + /** + * Set X. + * + * @param x + * @return new vector + */ + public Vector setX(double x) { + return new Vector(x, y, z); + } + + /** + * Set X. + * + * @param x + * @return new vector + */ + public Vector setX(int x) { + return new Vector(x, y, z); + } + /** * @return the y */ @@ -113,6 +133,26 @@ public class Vector { return (int)Math.round(y); } + /** + * Set Y. + * + * @param y + * @return new vector + */ + public Vector setY(double y) { + return new Vector(x, y, z); + } + + /** + * Set Y. + * + * @param y + * @return new vector + */ + public Vector setY(int y) { + return new Vector(x, y, z); + } + /** * @return the z */ @@ -127,6 +167,26 @@ public class Vector { return (int)Math.round(z); } + /** + * Set Z. + * + * @param z + * @return new vector + */ + public Vector setZ(double z) { + return new Vector(x, y, z); + } + + /** + * Set Z. + * + * @param z + * @return new vector + */ + public Vector setZ(int z) { + return new Vector(x, y, z); + } + /** * Adds two points. *