Advertisement
Guest User

Untitled

a guest
Oct 30th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. package com.khufu.stonetitans.gui.container;
  2.  
  3. import com.khufu.stonetitans.entity.EntityClone;
  4. import com.khufu.stonetitans.inventory.InventoryClone;
  5.  
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.entity.player.InventoryPlayer;
  8. import net.minecraft.inventory.Container;
  9. import net.minecraft.inventory.IInventory;
  10. import net.minecraft.inventory.Slot;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.world.World;
  13.  
  14. public class ContainerClone extends Container {
  15.  
  16. private IInventory lowerChestInventory;
  17. private int numRows;
  18.  
  19.  
  20. public ContainerClone(InventoryPlayer inventory, InventoryClone c_inventory) {
  21. this.lowerChestInventory = c_inventory;
  22. this.numRows = c_inventory.getSizeInventory() / 9;
  23. c_inventory.openInventory();
  24. int i = (this.numRows - 4) * 18;
  25. int j;
  26. int k;
  27.  
  28. for (j = 0; j < 3; ++j) {
  29. for (k = 0; k < 9; ++k) {
  30. this.addSlotToContainer(new Slot(c_inventory, k + j * 9 + 9, 8 + k * 18, 18 + j * 18 + i));
  31. }
  32. }
  33.  
  34. for (j = 0; j < 9; ++j) {
  35. this.addSlotToContainer(new Slot(c_inventory, j, 8 + j * 18, 77 + i));
  36. }
  37.  
  38.  
  39.  
  40. for (j = 0; j < 3; ++j) {
  41. for (k = 0; k < 9; ++k) {
  42. this.addSlotToContainer(new Slot(inventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
  43. }
  44. }
  45.  
  46. for (j = 0; j < 9; ++j) {
  47. this.addSlotToContainer(new Slot(inventory, j, 8 + j * 18, 161 + i));
  48. }
  49. }
  50.  
  51.  
  52. public ContainerClone(InventoryClone inventory, boolean b, EntityClone entityClone) {
  53. // TODO Auto-generated constructor stub
  54. }
  55.  
  56.  
  57. public boolean canInteractWith(EntityPlayer p_75145_1_) {
  58. return this.lowerChestInventory.isUseableByPlayer(p_75145_1_);
  59. }
  60.  
  61.  
  62. @Override
  63. public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
  64. {
  65. ItemStack itemstack = null;
  66. Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
  67.  
  68. if (slot != null && slot.getHasStack())
  69. {
  70. ItemStack itemstack1 = slot.getStack();
  71. itemstack = itemstack1.copy();
  72.  
  73. if (p_82846_2_ < this.numRows * 9)
  74. {
  75. if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true))
  76. {
  77. return null;
  78. }
  79. }
  80. else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false))
  81. {
  82. return null;
  83. }
  84.  
  85. if (itemstack1.stackSize == 0)
  86. {
  87. slot.putStack((ItemStack)null);
  88. }
  89. else
  90. {
  91. slot.onSlotChanged();
  92. }
  93. }
  94.  
  95. return itemstack;
  96. }
  97.  
  98.  
  99. public void onContainerClosed(EntityPlayer p_75134_1_) {
  100. super.onContainerClosed(p_75134_1_);
  101. this.lowerChestInventory.closeInventory();
  102. }
  103.  
  104.  
  105. public IInventory getLowerChestInventory() {
  106. return this.lowerChestInventory;
  107. }
  108.  
  109.  
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement