Added //walls.

This commit is contained in:
sk89q 2010-10-18 10:45:03 -07:00
parent 33ff7fb34c
commit 6c33aa44e2
2 changed files with 45 additions and 2 deletions

View File

@ -570,7 +570,7 @@ public class EditSession {
/**
* Make faces of the region (as if it was a cuboid if it's not).
*
*
* @param region
* @param block
* @return number of blocks affected
@ -582,7 +582,7 @@ public class EditSession {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
if (setBlock(new Vector(x, y, min.getBlockZ()), block)) { affected++; }
@ -608,6 +608,39 @@ public class EditSession {
return affected;
}
/**
* Make walls of the region (as if it was a cuboid if it's not).
*
* @param region
* @param block
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int makeCuboidWalls(Region region, BaseBlock block)
throws MaxChangedBlocksException {
int affected = 0;
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
if (setBlock(new Vector(x, y, min.getBlockZ()), block)) { affected++; }
if (setBlock(new Vector(x, y, max.getBlockZ()), block)) { affected++; }
affected++;
}
}
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if (setBlock(new Vector(min.getBlockX(), y, z), block)) { affected++; }
if (setBlock(new Vector(max.getBlockX(), y, z), block)) { affected++; }
}
}
return affected;
}
/**
* Overlays a layer of blocks over a cuboid area.
*

View File

@ -123,6 +123,7 @@ public class WorldEdit {
commands.put("//size", "Get size of selected region");
commands.put("//set", "[ID] - Set all blocks inside region");
commands.put("//outline", "[ID] - Outline the region with blocks");
commands.put("//walls", "[ID] - Build walls");
commands.put("//replace", "<FromID> [ToID] - Replace all existing blocks inside region");
commands.put("//overlay", "[ID] - Overlay the area one layer");
commands.put("/removeabove", "<Size> <Height> - Remove blocks above head");
@ -575,6 +576,15 @@ public class WorldEdit {
return true;
// Set the walls of a region
} else if(split[0].equalsIgnoreCase("//walls")) {
checkArgs(split, 1, 1, split[0]);
BaseBlock block = getBlock(split[1]);
int affected = editSession.makeCuboidWalls(session.getRegion(), block);
player.print(affected + " block(s) have been changed.");
return true;
// Drain pools
} else if(split[0].equalsIgnoreCase("//drain")) {
checkArgs(split, 1, 1, split[0]);