From 3dabcdacd1aa986dcd06067f4e33fa6c2cf1091a Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sat, 10 Dec 2011 12:16:57 +0100 Subject: [PATCH] Made /green break on liquids. --- .../java/com/sk89q/worldedit/EditSession.java | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 1e10d6883..c0bcba033 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2361,35 +2361,45 @@ public class EditSession { public int green(Vector pos, double radius) throws MaxChangedBlocksException { int affected = 0; - double radiusSq = radius * radius; + final double radiusSq = radius * radius; - int ox = pos.getBlockX(); - int oy = pos.getBlockY(); - int oz = pos.getBlockZ(); + final int ox = pos.getBlockX(); + final int oy = pos.getBlockY(); + final int oz = pos.getBlockZ(); - BaseBlock grass = new BaseBlock(BlockID.GRASS); + final BaseBlock grass = new BaseBlock(BlockID.GRASS); - int ceilRadius = (int) Math.ceil(radius); + final int ceilRadius = (int) Math.ceil(radius); for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { continue; } - for (int y = 127; y >= 1; --y) { - Vector pt = new Vector(x, y, z); - int id = getBlockType(pt); + loop: for (int y = 127; y >= 1; --y) { + final Vector pt = new Vector(x, y, z); + final int id = getBlockType(pt); - if (BlockType.canPassThrough(id)) { - continue; - } - - if (id == BlockID.DIRT) { + switch (id) { + case BlockID.DIRT: if (setBlock(pt, grass)) { ++affected; } + break loop; + + case BlockID.WATER: + case BlockID.STATIONARY_WATER: + case BlockID.LAVA: + case BlockID.STATIONARY_LAVA: + // break on liquids... + break loop; + + default: + // ...and all non-passable blocks + if (!BlockType.canPassThrough(id)) { + break loop; + } } - break; } } }