mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Correctly check for null values in EditSession.replaceBlocks()
This commit is contained in:
parent
2f2d3f8045
commit
4bb5b56da8
@ -1248,11 +1248,13 @@ public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes, BaseBlock
|
|||||||
Set<BaseBlock> definiteBlockTypes = new HashSet<BaseBlock>();
|
Set<BaseBlock> definiteBlockTypes = new HashSet<BaseBlock>();
|
||||||
Set<Integer> fuzzyBlockTypes = new HashSet<Integer>();
|
Set<Integer> fuzzyBlockTypes = new HashSet<Integer>();
|
||||||
|
|
||||||
for (BaseBlock block : fromBlockTypes) {
|
if (fromBlockTypes != null) {
|
||||||
if (block.getData() == -1) {
|
for (BaseBlock block : fromBlockTypes) {
|
||||||
fuzzyBlockTypes.add(block.getType());
|
if (block.getData() == -1) {
|
||||||
} else {
|
fuzzyBlockTypes.add(block.getType());
|
||||||
definiteBlockTypes.add(block);
|
} else {
|
||||||
|
definiteBlockTypes.add(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1275,9 +1277,17 @@ public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes, BaseBlock
|
|||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
BaseBlock curBlockType = getBlock(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
//replace <from-block> <to-block>
|
|
||||||
if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) {
|
if (fromBlockTypes == null) {
|
||||||
continue;
|
//replace <to-block>
|
||||||
|
if (curBlockType.isAir()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//replace <from-block> <to-block>
|
||||||
|
if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
@ -1290,9 +1300,16 @@ public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes, BaseBlock
|
|||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
BaseBlock curBlockType = getBlock(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
|
|
||||||
//replace <from-block> <to-block>
|
if (fromBlockTypes == null) {
|
||||||
if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) {
|
//replace <to-block>
|
||||||
continue;
|
if (curBlockType.isAir()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//replace <from-block> <to-block>
|
||||||
|
if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user