diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 73fdf0788..2fe324eb0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -1209,6 +1209,11 @@ public class BrushCommands { Expression radius, @Arg(desc = "The height of the cylinder", def = "1") int height, + //FAWE start - hcyl thickness + @Arg(desc = "The thickness of the cylinder. Requires -h switch be given. 0 creates a standard hollow cylinder.", + def = "0") + double thickness, + //FAWE end @Switch(name = 'h', desc = "Create hollow cylinders instead") boolean hollow ) throws WorldEditException { @@ -1217,7 +1222,9 @@ public class BrushCommands { BrushSettings settings; if (hollow) { - settings = set(context, new HollowCylinderBrush(height)); + //FAWE start - hcyl thickness + settings = set(context, new HollowCylinderBrush(height, thickness)); + //FAWE end } else { settings = set(context, new CylinderBrush(height)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 2e3158489..94e5c425f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -103,10 +103,42 @@ public class GenerationCommands { @Radii(2) List radii, @Arg(desc = "The height of the cylinder", def = "1") - int height + int height, + //FAWE start - hcyl thickness + @Arg(desc = "Thickness of the cyclinder. 0 creates a normal //hcyl.", def = "0") + double thickness ) throws WorldEditException { - return cyl(actor, session, editSession, pattern, radii, height, true); + final double radiusX; + final double radiusZ; + switch (radii.size()) { + case 1: + radiusX = radiusZ = Math.max(1, radii.get(0)); + break; + + case 2: + radiusX = Math.max(1, radii.get(0)); + radiusZ = Math.max(1, radii.get(1)); + break; + + default: + actor.print(Caption.of("worldedit.cyl.invalid-radius")); + return 0; + } + worldEdit.checkMaxRadius(radiusX); + worldEdit.checkMaxRadius(radiusZ); + worldEdit.checkMaxRadius(height); + + if (thickness > radiusX || thickness > radiusZ) { + actor.print(Caption.of("worldedit.hcyl.thickness-too-large")); + return 0; + } + + BlockVector3 pos = session.getPlacementPosition(actor); + int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, thickness, false); + actor.print(Caption.of("worldedit.cyl.created", TextComponent.of(affected))); + return affected; } + //FAWE end @Command( name = "/cyl", diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java index d1789d91a..c72bb9639 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java @@ -28,9 +28,15 @@ import com.sk89q.worldedit.world.block.BlockTypes; public class HollowCylinderBrush implements Brush { private final int height; + //FAWE start - hcyl thickness + private final double thickness; + //FAWE end - public HollowCylinderBrush(int height) { + public HollowCylinderBrush(int height, double thickness) { this.height = height; + //FAWE start - hcyl thickness + this.thickness = thickness; + //FAWE end } @Override @@ -39,7 +45,9 @@ public class HollowCylinderBrush implements Brush { if (pattern == null) { pattern = BlockTypes.COBBLESTONE.getDefaultState(); } - editSession.makeCylinder(position, pattern, size, size, height, false); + //FAWE start - hcyl thickness + editSession.makeCylinder(position, pattern, size, size, height, thickness, false); + //FAWE end } } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index b92423513..886e2b70a 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -494,6 +494,7 @@ "worldedit.cyl.invalid-radius": "You must either specify 1 or 2 radius values.", "worldedit.cyl.created": "{0} blocks have been created.", + "worldedit.hcyl.thickness-too-large": "Thickness cannot be larger than x or z radii.", "worldedit.sphere.invalid-radius": "You must either specify 1 or 3 radius values.", "worldedit.sphere.created": "{0} blocks have been created.", "worldedit.forestgen.created": "{0} trees created.",