forked from LogBlock/LogBlock
Made "trapped chest" content rollbackable
This commit is contained in:
@@ -162,21 +162,24 @@ public class WorldEditor implements Runnable
|
|||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (!block.setTypeId(0))
|
if (!block.setTypeId(0))
|
||||||
throw new WorldEditorException(block.getTypeId(), 0, block.getLocation());
|
throw new WorldEditorException(block.getTypeId(), 0, block.getLocation());
|
||||||
} else if (ca != null && (type == 23 || type == 54 || type == 61 || type == 62)) {
|
} else if (ca != null ) {
|
||||||
int leftover;
|
boolean chest = (type == 54 || type == 146);
|
||||||
try {
|
if (chest || type == 23 || type == 61 || type == 62) {
|
||||||
leftover = modifyContainer(state, new ItemStack(ca.itemType, -ca.itemAmount, ca.itemData));
|
int leftover;
|
||||||
if (leftover > 0)
|
try {
|
||||||
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
|
leftover = modifyContainer(state, new ItemStack(ca.itemType, -ca.itemAmount, ca.itemData));
|
||||||
if (block.getRelative(face).getTypeId() == 54)
|
if (leftover > 0 && chest)
|
||||||
leftover = modifyContainer(block.getRelative(face).getState(), new ItemStack(ca.itemType, ca.itemAmount < 0 ? leftover : -leftover, ca.itemData));
|
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
|
||||||
} catch (final Exception ex) {
|
if (block.getRelative(face).getTypeId() == type)
|
||||||
throw new WorldEditorException(ex.getMessage(), block.getLocation());
|
leftover = modifyContainer(block.getRelative(face).getState(), new ItemStack(ca.itemType, ca.itemAmount < 0 ? leftover : -leftover, ca.itemData));
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
throw new WorldEditorException(ex.getMessage(), block.getLocation());
|
||||||
|
}
|
||||||
|
if (!state.update())
|
||||||
|
throw new WorldEditorException("Failed to update inventory of " + materialName(block.getTypeId()), block.getLocation());
|
||||||
|
if (leftover > 0 && ca.itemAmount < 0)
|
||||||
|
throw new WorldEditorException("Not enough space left in " + materialName(block.getTypeId()), block.getLocation());
|
||||||
}
|
}
|
||||||
if (!state.update())
|
|
||||||
throw new WorldEditorException("Failed to update inventory of " + materialName(block.getTypeId()), block.getLocation());
|
|
||||||
if (leftover > 0 && ca.itemAmount < 0)
|
|
||||||
throw new WorldEditorException("Not enough space left in " + materialName(block.getTypeId()), block.getLocation());
|
|
||||||
} else
|
} else
|
||||||
return PerformResult.NO_ACTION;
|
return PerformResult.NO_ACTION;
|
||||||
return PerformResult.SUCCESS;
|
return PerformResult.SUCCESS;
|
||||||
|
Reference in New Issue
Block a user