Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public class UndoChest extends UndoBlock {
  2.  
  3. private ItemStack[] is;
  4.  
  5. public UndoChest(BlockState state) {
  6. super(state);
  7. for (ItemStack id : ((InventoryHolder) state).getInventory().getContents()) {
  8. if (id != null)
  9. Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
  10. }
  11. this.is = ((InventoryHolder) state).getInventory().getContents();
  12. for (ItemStack id : ((InventoryHolder) state).getInventory().getContents()) {
  13. if (id != null)
  14. Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
  15. }
  16. }
  17.  
  18. @Override
  19. public void undo() {
  20. if (is != null && state != null) {
  21. state.update(true);
  22. for (ItemStack id : is) {
  23. if (id != null)
  24. Util.info("Type: " + id.getType().name() + " Amount: " + id.getAmount());
  25. }
  26. Inventory inv2 = ((InventoryHolder) state.getBlock().getState()).getInventory();
  27. inv2.setContents(is);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement