Added /removenear.

This commit is contained in:
sk89q
2010-10-18 16:36:22 -07:00
parent 94876194c4
commit ccab458d9c
2 changed files with 43 additions and 0 deletions

View File

@ -481,6 +481,36 @@ public class EditSession {
return affected;
}
/**
* Remove nearby blocks of a type.
*
* @param pos
* @param blockType
* @param size
* @return number of blocks affected
*/
public int removeNear(Vector pos, int blockType, int size) throws
MaxChangedBlocksException {
int affected = 0;
BaseBlock air = new BaseBlock(0);
for (int x = -size; x <= size; x++) {
for (int y = -size; y <= size; y++) {
for (int z = -size; z <= size; z++) {
Vector p = pos.add(x, y, z);
if (getBlock(p).getID() == blockType) {
if (setBlock(p, air)) {
affected++;
}
}
}
}
}
return affected;
}
/**
* Sets all the blocks inside a region to a certain block type.
*