Guest User

Untitled

a guest
Nov 11th, 2016
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package thecraft.mod.common;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.entity.player.InventoryPlayer;
  5. import net.minecraft.inventory.Container;
  6. import net.minecraft.inventory.Slot;
  7. import net.minecraft.item.ItemStack;
  8.  
  9. public class ContainerEwiliteChest extends Container
  10. {
  11.  
  12. private final TileEntityEwiliteChest tileEwilite;
  13.  
  14. public ContainerEwiliteChest(TileEntityEwiliteChest tile, InventoryPlayer inventory)
  15. {
  16. this.tileEwilite = tile;
  17. tile.openInventory();
  18. for(int i = 0; i < 3; ++i)
  19. {
  20. for(int j = 0; j < 9; ++j)
  21. {
  22. this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18, 18 + i * 18));
  23. }
  24. }
  25. this.bindPlayerInventory(inventory);
  26. }
  27. private void bindPlayerInventory(InventoryPlayer inventory)
  28. {
  29. int i;
  30. for(i = 0; i < 3; ++i)
  31. {
  32. for(int j = 0; j < 9; ++j)
  33. {
  34. this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 86 + i * 18));
  35. }
  36. }
  37.  
  38. for(i = 0; i < 9; ++i)
  39. {
  40. this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 144));
  41. }
  42. }
  43. public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
  44. {
  45. ItemStack itemstack = null;
  46. Slot slot = (Slot)this.inventorySlots.get(slotIndex);
  47.  
  48. if(slot != null && slot.getHasStack())
  49. {
  50. ItemStack itemstack1 = slot.getStack();
  51. itemstack = itemstack1.copy();
  52.  
  53. if(slotIndex < this.tileEwilite.getSizeInventory())
  54. {
  55. if(!this.mergeItemStack(itemstack1, this.tileEwilite.getSizeInventory(), this.inventorySlots.size(), true))
  56. {
  57. return null;
  58. }
  59. }
  60. else if(!this.mergeItemStack(itemstack1, 0, this.tileEwilite.getSizeInventory(), false))
  61. {
  62. return null;
  63. }
  64.  
  65. if(itemstack1.stackSize == 0)
  66. {
  67. slot.putStack((ItemStack)null);
  68. }
  69. else
  70. {
  71. slot.onSlotChanged();
  72. }
  73. }
  74. return itemstack;
  75. }
  76. @Override
  77. public boolean canInteractWith(EntityPlayer player)
  78. {
  79. return this.tileEwilite.isUseableByPlayer(player);
  80. }
  81. public void onContainerClosed(EntityPlayer player)
  82. {
  83. super.onContainerClosed(player);
  84. this.tileEwilite.closeInventory();
  85. }
  86. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×