Permalink
Browse files

Merge pull request #437 from JOO200/master

Add check for unchanged materials in BlockBagExtent
  • Loading branch information...
me4502 committed Dec 6, 2018
2 parents be0d21e + a73faf0 commit b1d8d4901df7b6c18faecf8d8daba4f02dbd110f
Showing with 18 additions and 16 deletions.
  1. +18 −16 worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java
@@ -86,25 +86,27 @@ public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws Wo
if (blockBag != null) {
BlockState existing = getExtent().getBlock(position);
if (!block.getBlockType().getMaterial().isAir()) {
try {
blockBag.fetchPlacedBlock(block.toImmutableState());
} catch (UnplaceableBlockException e) {
return false;
} catch (BlockBagException e) {
if (!missingBlocks.containsKey(block.getBlockType())) {
missingBlocks.put(block.getBlockType(), 1);
} else {
missingBlocks.put(block.getBlockType(), missingBlocks.get(block.getBlockType()) + 1);
if (!block.getBlockType().equals(existing.getBlockType())) {
if (!block.getBlockType().getMaterial().isAir()) {
try {
blockBag.fetchPlacedBlock(block.toImmutableState());
} catch (UnplaceableBlockException e) {
return false;
} catch (BlockBagException e) {
if (!missingBlocks.containsKey(block.getBlockType())) {
missingBlocks.put(block.getBlockType(), 1);
} else {
missingBlocks.put(block.getBlockType(), missingBlocks.get(block.getBlockType()) + 1);
}
return false;
}
return false;
}
}
if (!existing.getBlockType().getMaterial().isAir()) {
try {
blockBag.storeDroppedBlock(existing);
} catch (BlockBagException ignored) {
if (!existing.getBlockType().getMaterial().isAir()) {
try {
blockBag.storeDroppedBlock(existing);
} catch (BlockBagException ignored) {
}
}
}
}

0 comments on commit b1d8d49

Please sign in to comment.