Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.92 KB | None | 0 0
  1. public class ContainerDeciInventory extends Container {
  2. private static final String __OBFID = "CL_00001754";
  3. private final EntityPlayer thePlayer;
  4.  
  5. public InventoryDeci invDeci;
  6.  
  7. public InventoryGeneric invCorpse;
  8. /**
  9. * Determines if inventory manipulation should be handled.
  10. */
  11. public boolean isLocalWorld;
  12. public int w;
  13. public int h;
  14. public int type;
  15. ItemStack prevIt = null;
  16. private RagdollCorpse corpse;
  17.  
  18. private int backslots = 0;
  19.  
  20. public ContainerDeciInventory(final InventoryPlayer p_i1819_1_, EntityPlayer p_i1819_3_, int cid, int type) {
  21. this(p_i1819_1_, false, p_i1819_3_, 0, 0, cid, type);
  22. }
  23.  
  24. public ContainerDeciInventory(final InventoryPlayer p_i1819_1_, boolean p_i1819_2_, EntityPlayer player, int width, int height, int cid, int type) {
  25. this.thePlayer = player;
  26.  
  27. /* if (cid > -1) {
  28. if (cid < RagdollCorpse.pcorpseList.size()) {
  29. corpse = RagdollCorpse.pcorpseList.get(cid);
  30. }
  31. }*/
  32.  
  33. initContainer(p_i1819_1_, p_i1819_2_, player, width, height, type);
  34. }
  35.  
  36. public void initContainer(final InventoryPlayer p_i1819_1_, boolean p_i1819_2_, EntityPlayer player, int width, int height, int type) {
  37. if (width == -1) {
  38. return;
  39. }
  40. this.type = type;
  41. inventorySlots.clear();
  42. this.inventoryItemStacks.clear();
  43. this.isLocalWorld = p_i1819_2_;
  44.  
  45. invDeci = new InventoryDeci(this, player);
  46. w = width;
  47. h = height;
  48. // this.addSlotToContainer(new SlotCrafting(p_i1819_1_.player, this.craftMatrix, this.craftResult, 0, 144, 36));
  49. int i;
  50. int j;
  51.  
  52. /* for (i = 0; i < 2; ++i)
  53. {
  54. for (j = 0; j < 2; ++j)
  55. {
  56. this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18));
  57. }
  58. }*/
  59.  
  60. // 120, height / 2 - 65;
  61.  
  62. for (i = 0; i < 4; ++i) {
  63. final int k = i;
  64. this.addSlotToContainer(new Slot(p_i1819_1_, p_i1819_1_.getSizeInventory() - 1 - i, 121, (height / 2) - 64 + i * 20) {
  65. private static final String __OBFID = "CL_00001755";
  66.  
  67. /**
  68. * Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1
  69. * in the case of armor slots)
  70. */
  71. public int getSlotStackLimit() {
  72. return 1;
  73. }
  74.  
  75. /**
  76. * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
  77. */
  78. public boolean isItemValid(ItemStack stack) {
  79. if (stack == null) return false;
  80. return stack.getItem().isValidArmor(stack, k, thePlayer);
  81. }
  82. });
  83. }
  84.  
  85. for (i = 0; i < 3; ++i) {
  86. for (j = 0; j < 9; ++j) {
  87. this.addSlotToContainer(new Slot(p_i1819_1_, j + (i + 1) * 9, ((width / 2) - (176 / 2) + 8) + j * 18, (height - 107) + i * 18));
  88. }
  89. }
  90.  
  91. for (i = 0; i < 9; ++i) {
  92. this.addSlotToContainer(new Slot(p_i1819_1_, i, ((width / 2) - (176 / 2) + 8) + i * 18, height - 39));
  93. }
  94.  
  95.  
  96. CommonPlayerData data = CommonPlayerData.get(player);
  97.  
  98. // this.onCraftMatrixChanged(this.craftMatrix);
  99. int backPosX = width / 2 + 200 - 20;
  100. int backPosY = height / 2 - 85;
  101.  
  102. int rows = (((data.getBackpack() != null && data.getBackpack().getItem() instanceof ItemBackpack ? ((ItemBackpack) data.getBackpack().getItem()).capacity : 0) + 2) / 3) - 1;
  103. int row = 0;
  104.  
  105. backPosX -= (rows * 20) + 20;
  106.  
  107. invDeci.editing = true;
  108. this.addSlotToContainer(new SlotRestrictable(invDeci, 0, backPosX, backPosY));
  109. if (data.getBackpack() != null)
  110. invDeci.setInventorySlotContents(0, data.getBackpack());
  111.  
  112. this.addSlotToContainer(new SlotRestrictable(invDeci, 1, 100 + 1, height / 2 - 65 + 1));
  113. this.addSlotToContainer(new SlotRestrictable(invDeci, 2, 140 + 1, height / 2 - 65 + (20) + 1));
  114.  
  115. if (data.getMask() != null)
  116. invDeci.setInventorySlotContents(1, data.getMask());
  117.  
  118. if (data.getVest() != null)
  119. invDeci.setInventorySlotContents(2, data.getVest());
  120. invDeci.editing = false;
  121.  
  122.  
  123. if (data.getBackpack() != null && data.getBackpack().getItem() instanceof ItemBackpack) {
  124. ItemBackpack pack = (ItemBackpack) data.getBackpack().getItem();
  125. InventoryBackpack invBackpack = new InventoryBackpack(data, this);
  126. invBackpack.adding = true;
  127.  
  128. backslots = pack.capacity;
  129.  
  130. int y = 0;
  131. for (i = 0; i < pack.capacity; i++) {
  132. int xp = width / 2 + 200 - 20;
  133. int yp = height / 2 - 85;
  134. this.addSlotToContainer(new SlotRestrictable(invBackpack, i, xp - (20 * (rows - row)), yp + (y * 20)));
  135. invBackpack.setInventorySlotContents(i, pack.getStackInSlot(data.getBackpack(), i));
  136. if (y == 2) {
  137. row++;
  138. y = 0;
  139. } else {
  140. y++;
  141. }
  142. }
  143.  
  144. invBackpack.adding = false;
  145. //invBackpack.markDirty();
  146. }
  147.  
  148. //data.openCorpse.data = data;
  149. if (data.getOpenCorpse() != null && type == 1) {
  150. data.getOpenCorpse().adding = true;
  151. // invCorpse = new InventoryGeneric(corpse, corpse.getSizeInventory());
  152. rows = (data.getOpenCorpse().getSizeInventory() / 2) - 1;
  153. row = 0;
  154. int y = 0;
  155. for (i = 0; i < data.getOpenCorpse().getSizeInventory(); i++) {
  156. int xp = width / 2 + 280 - 20;
  157. int yp = height / 2 + 15;
  158. this.addSlotToContainer(new Slot(data.getOpenCorpse(), i, xp - (20 * (rows - row)), yp + (y * 20)));
  159. //invCorpse.setInventorySlotContentsNo(i, corpse.getStackInSlot(i));
  160. if (row == 3) {
  161. y++;
  162. row = 0;
  163. } else {
  164. row++;
  165. }
  166. }
  167. data.getOpenCorpse().adding = false;
  168. }
  169.  
  170.  
  171. if (data.getOpenLoot() != null && type == 2) {
  172. rows = (data.getOpenLoot().getSizeInventory() / 2) - 1;
  173. row = 0;
  174. int y = 0;
  175. for (i = 0; i < data.getOpenLoot().getSizeInventory(); i++) {
  176. int xp = width / 2 - 200;
  177. int yp = height / 2 + 55;
  178. this.addSlotToContainer(new Slot(data.getOpenLoot(), i, xp + (20 * (row)), yp + (y * 20)));
  179. //invCorpse.setInventorySlotContents(i, corpse.getStackInSlot(i));
  180. if (y == 3) {
  181. row++;
  182. y = 0;
  183. } else {
  184. y++;
  185. }
  186. }
  187. }
  188. }
  189.  
  190. /**
  191. * Callback for when the crafting matrix is changed.
  192. */
  193. public void onCraftMatrixChanged(IInventory p_75130_1_) {
  194. //this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj));
  195. }
  196.  
  197. /**
  198. * Called when the container is closed.
  199. */
  200. public void onContainerClosed(EntityPlayer player) {
  201. super.onContainerClosed(player);
  202.  
  203. // p_75134_1_.inventoryContainer.detectAndSendChanges();
  204. /* for (int i = 0; i < 4; ++i)
  205. {
  206. ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
  207.  
  208. if (itemstack != null)
  209. {
  210. p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false);
  211. }
  212. }
  213.  
  214. this.craftResult.setInventorySlotContents(0, (ItemStack)null);*/
  215. }
  216.  
  217. public boolean canInteractWith(EntityPlayer player) {
  218. return true;
  219. }
  220.  
  221. /**
  222. * Take a stack from the specified inventory slot.
  223. */
  224. public ItemStack transferStackInSlot(EntityPlayer player, int index) {
  225. return null;
  226. /* ItemStack itemstack = null;
  227. Slot slot = (Slot) this.inventorySlots.get(index);
  228.  
  229. if (slot != null && slot.getHasStack()) {
  230. ItemStack itemstack1 = slot.getStack();
  231. itemstack = itemstack1.copy();*/
  232.  
  233. /* if (index == 0)
  234. {
  235. if (!this.mergeItemStack(itemstack1, 9, 45, true))
  236. {
  237. return null;
  238. }
  239.  
  240. slot.onSlotChange(itemstack1, itemstack);
  241. }*/
  242. /* else if (index >= 1 && index < 5)
  243. {
  244. if (!this.mergeItemStack(itemstack1, 9, 45, false))
  245. {
  246. return null;
  247. }
  248. }
  249. else if (index >= 5 && index < 9)
  250. {
  251. if (!this.mergeItemStack(itemstack1, 9, 45, false))
  252. {
  253. return null;
  254. }
  255. }*/
  256. /* else */
  257. /* if (itemstack.getItem() instanceof ItemArmor && !((Slot) this.inventorySlots.get(((ItemArmor) itemstack.getItem()).armorType)).getHasStack()) {
  258. int j = ((ItemArmor) itemstack.getItem()).armorType;
  259.  
  260. if (!this.mergeItemStack(itemstack1, j, j + 1, false)) {
  261. return null;
  262. }
  263. } else if (index < 4) {
  264. if (!this.mergeItemStack(itemstack1, 4, 4 + 9, false)) {
  265. return null;
  266. }
  267. } else if (index > 4 + 9) {
  268. if (!this.mergeItemStack(itemstack1, 4, 4 + 9, false)) {
  269. return null;
  270. }
  271. }
  272. /*else if (index >= 9 && index < 36)
  273. {
  274. if (!this.mergeItemStack(itemstack1, 36, 45, false))
  275. {
  276. return null;
  277. }
  278. }
  279. else if (index >= 36 && index < 45)
  280. {
  281. if (!this.mergeItemStack(itemstack1, 9, 36, false))
  282. {
  283. return null;
  284. }
  285. }
  286. else if (!this.mergeItemStack(itemstack1, 9, 45, false))
  287. {
  288. return null;
  289. }*/
  290.  
  291. /* if (itemstack1.stackSize == 0) {
  292. slot.putStack((ItemStack) null);
  293. } else {
  294. slot.onSlotChanged();
  295. }
  296.  
  297. if (itemstack1.stackSize == itemstack.stackSize) {
  298. return null;
  299. }
  300.  
  301. slot.onPickupFromSlot(player, itemstack1);
  302. }*/
  303.  
  304. //return itemstack;
  305. }
  306.  
  307. public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) {
  308. return /*p_94530_2_.inventory != this.craftResult && */super.func_94530_a(p_94530_1_, p_94530_2_);
  309. }
  310.  
  311. /**
  312. * Handles slot click. Args : slotId, clickedButton, mode (0 = basic click, 1 = shift click, 2 = Hotbar, 3 =
  313. * pickBlock, 4 = Drop, 5 = ?, 6 = Double click), player
  314. *
  315. * @param slotId Will be either the slot id in the current Container or -999 if dragging
  316. * @param mode 0 for basic click, 1 for shift-click, 2 for hotbar, 3 for pickBlock, 4 for drop, 5 for item
  317. * distribution drag, 6 for double click
  318. */
  319. public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
  320. ItemStack itemstack = super.slotClick(slotId, clickedButton, mode, player);
  321. if (player.inventory.getItemStack() != prevIt && !player.worldObj.isRemote && slotId > 16 && slotId < 16 + backslots) {
  322. Decimation.mainNetworkChannel.sendTo(new Message_PInv_Stack(player.inventory.getItemStack()), (EntityPlayerMP) player);
  323. }
  324. return itemstack;
  325. }
  326. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement