diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index c081a1c6c..e20049ec5 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -1570,6 +1570,54 @@ public class EditSession { return affected; } + /** + * Thaw. + * + * @param pos + * @param radius + * @return number of blocks affected + * @throws MaxChangedBlocksException + */ + public int thaw(Vector pos, int radius) + throws MaxChangedBlocksException { + int affected = 0; + int radiusSq = (int)Math.pow(radius, 2); + + int ox = pos.getBlockX(); + int oy = pos.getBlockY(); + int oz = pos.getBlockZ(); + + BaseBlock air = new BaseBlock(0); + BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER); + + for (int x = ox - radius; x <= ox + radius; x++) { + for (int z = oz - radius; z <= oz + radius; 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 = getBlock(pt).getID(); + + if (id == BlockID.ICE) { // Ice + if (setBlock(pt, water)) { + affected++; + } + } else if (id == BlockID.SNOW) { + if (setBlock(pt, air)) { + affected++; + } + } else if (id != 0) { + break; + } + } + } + } + + return affected; + } + /** * Make snow. * diff --git a/src/com/sk89q/worldedit/WorldEditController.java b/src/com/sk89q/worldedit/WorldEditController.java index a0744a711..d650617c5 100644 --- a/src/com/sk89q/worldedit/WorldEditController.java +++ b/src/com/sk89q/worldedit/WorldEditController.java @@ -155,6 +155,7 @@ public class WorldEditController { commands.put("/forestgen", " - Make Notch tree forest"); commands.put("/pinegen", " - Make an ugly pine tree forest"); commands.put("/snow", " - Simulate snow cover"); + commands.put("/thaw", " - Unthaw/remove snow"); commands.put("/pumpkins", " - Make a pumpkin forest"); commands.put("/unstuck", "Go up to the first free spot"); commands.put("/ascend", "Go up one level"); @@ -1219,6 +1220,16 @@ public class WorldEditController { return true; + // Thaw + } else if (split[0].equalsIgnoreCase("/thaw")) { + checkArgs(split, 0, 1, split[0]); + int size = split.length > 1 ? Math.max(1, Integer.parseInt(split[1])) : 10; + + int affected = editSession.thaw(player.getBlockIn(), size); + player.print(affected + " surfaces thawed."); + + return true; + // Make pumpkin patches } else if (split[0].equalsIgnoreCase("/pumpkins")) { checkArgs(split, 0, 1, split[0]);