From 61905527f854983a46915c06c1376fc6fce28ad0 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 29 Dec 2013 18:28:42 +0100 Subject: [PATCH] The /green command no longer affects permadirt and podzol. This behaviour can be overridden with -f. --- .../java/com/sk89q/worldedit/EditSession.java | 20 +++++++++++++++++++ .../worldedit/commands/UtilityCommands.java | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 176c8dc74..b9c7268f8 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2504,9 +2504,25 @@ public class EditSession { * @param radius * @return number of blocks affected * @throws MaxChangedBlocksException + * @deprecated Use {@link #green(Vector, double, boolean)}. */ + @Deprecated public int green(Vector pos, double radius) throws MaxChangedBlocksException { + return green(pos, radius, true); + } + + /** + * Green. + * + * @param pos + * @param radius + * @param onlyNormalDirt only affect normal dirt (data value 0) + * @return number of blocks affected + * @throws MaxChangedBlocksException + */ + public int green(Vector pos, double radius, boolean onlyNormalDirt) + throws MaxChangedBlocksException { int affected = 0; final double radiusSq = radius * radius; @@ -2530,6 +2546,10 @@ public class EditSession { switch (id) { case BlockID.DIRT: + if (onlyNormalDirt && data != 0) { + break loop; + } + if (setBlock(pt, grass)) { ++affected; } diff --git a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java index f02d34695..bfba049b9 100644 --- a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java @@ -316,6 +316,7 @@ public class UtilityCommands { aliases = { "/green", "green" }, usage = "[radius]", desc = "Greens the area", + flags = "f", min = 0, max = 1 ) @@ -324,9 +325,10 @@ public class UtilityCommands { public void green(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { - double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; + final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; + final boolean onlyNormalDirt = !args.hasFlag('f'); - int affected = editSession.green(session.getPlacementPosition(player), size); + final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt); player.print(affected + " surfaces greened."); }