From a20ecc08871e3d15d0f8eafbb9a2f240647651ad Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 6 Nov 2010 21:54:03 -0700 Subject: [PATCH] Added /replacenear. --- src/WorldEditListener.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/WorldEditListener.java b/src/WorldEditListener.java index 6ff1a65cb..a7c7ef4f4 100644 --- a/src/WorldEditListener.java +++ b/src/WorldEditListener.java @@ -132,6 +132,7 @@ public class WorldEditListener extends PluginListener { commands.put("//outline", "[ID] - Outline the region with blocks"); commands.put("//walls", "[ID] - Build walls"); commands.put("//replace", " [ToID] - Replace all existing blocks inside region"); + commands.put("/replacenear", " [ToID] - Replace all existing blocks nearby"); commands.put("//overlay", "[ID] - Overlay the area one layer"); commands.put("/removeabove", " - Remove blocks above head"); commands.put("/removebelow", " - Remove blocks below position"); @@ -861,6 +862,29 @@ public class WorldEditListener extends PluginListener { return true; + // Replace all blocks in the region + } else if(split[0].equalsIgnoreCase("/replacenear")) { + checkArgs(split, 2, 3, split[0]); + int size = Math.max(1, Integer.parseInt(split[1])); + Set from; + BaseBlock to; + if (split.length == 3) { + from = null; + to = getBlock(split[2], true); + } else { + from = getBlockIDs(split[2]); + to = getBlock(split[3]); + } + + Vector min = player.getBlockIn().subtract(size, size, size); + Vector max = player.getBlockIn().add(size, size, size); + Region region = new CuboidRegion(min, max); + + int affected = editSession.replaceBlocks(region, from, to); + player.print(affected + " block(s) have been replaced."); + + return true; + // Lay blocks over an area } else if (split[0].equalsIgnoreCase("//overlay")) { checkArgs(split, 1, 1, split[0]);