Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UndoChest extends UndoBlock {
- private ItemStack[] is;
- public UndoChest(BlockState state) {
- super(state);
- for (ItemStack id : ((InventoryHolder) state).getInventory().getContents()) {
- if (id != null)
- Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
- }
- this.is = ((InventoryHolder) state).getInventory().getContents();
- for (ItemStack id : ((InventoryHolder) state).getInventory().getContents()) {
- if (id != null)
- Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
- }
- }
- @Override
- public void undo() {
- if (is != null && state != null) {
- state.update(true);
- for (ItemStack id : is) {
- if (id != null)
- Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
- }
- Inventory inv2 = ((InventoryHolder) state.getBlock().getState()).getInventory();
- inv2.setContents(is);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement