Added block damage support to //replace and //replacenear

This commit is contained in:
zml2008
2011-08-28 23:57:07 -07:00
parent d83fed13fb
commit 1562f17540
5 changed files with 55 additions and 20 deletions

View File

@ -999,7 +999,7 @@ public class EditSession {
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int replaceBlocks(Region region, Set<Integer> fromBlockTypes,
public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes,
BaseBlock toBlock) throws MaxChangedBlocksException {
int affected = 0;
@ -1019,11 +1019,10 @@ public class EditSession {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
int curBlockType = getBlockType(pt);
BaseBlock curBlockType = getBlock(pt);
if ((fromBlockTypes == null && curBlockType != 0)
|| (fromBlockTypes != null && fromBlockTypes
.contains(curBlockType))) {
if ((fromBlockTypes == null && !curBlockType.isAir())
|| (fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes))) {
if (setBlock(pt, toBlock)) {
++affected;
}
@ -1033,10 +1032,10 @@ public class EditSession {
}
} else {
for (Vector pt : region) {
int curBlockType = getBlockType(pt);
BaseBlock curBlockType = getBlock(pt);
if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) {
if (fromBlockTypes == null && !curBlockType.isAir()
|| fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes)) {
if (setBlock(pt, toBlock)) {
++affected;
}
@ -1056,7 +1055,7 @@ public class EditSession {
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int replaceBlocks(Region region, Set<Integer> fromBlockTypes,
public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes,
Pattern pattern) throws MaxChangedBlocksException {
int affected = 0;
@ -1076,11 +1075,10 @@ public class EditSession {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
int curBlockType = getBlockType(pt);
BaseBlock curBlockType = getBlock(pt);
if ((fromBlockTypes == null && curBlockType != 0)
|| (fromBlockTypes != null && fromBlockTypes
.contains(curBlockType))) {
if ((fromBlockTypes == null && !curBlockType.isAir())
|| (fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes))) {
if (setBlock(pt, pattern.next(pt))) {
++affected;
}
@ -1090,10 +1088,10 @@ public class EditSession {
}
} else {
for (Vector pt : region) {
int curBlockType = getBlockType(pt);
BaseBlock curBlockType = getBlock(pt);
if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) {
if (fromBlockTypes == null && !curBlockType.isAir()
|| curBlockType.inIterable(fromBlockTypes)) {
if (setBlock(pt, pattern.next(pt))) {
++affected;
}