Advertisement
RS_Darki

Untitled

Oct 25th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package me.darki.util;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.inventory.Container;
  5. import net.minecraft.inventory.IInventory;
  6. import net.minecraft.inventory.Slot;
  7. import net.minecraft.item.ItemStack;
  8.  
  9. public class containerMel extends Container {
  10.  
  11. @Override
  12. public boolean canInteractWith(EntityPlayer playerIn) {
  13. return true;
  14. }
  15.  
  16. public containerMel(IInventory playerInv, teMel tm) {
  17. int i = -18;
  18. int j;
  19. int k;
  20.  
  21. for (j = 0; j < 14; ++j){
  22. for (k = 0; k < 3; ++k) {
  23. //Input
  24. this.addSlotToContainer(new Slot(playerInv, 1, 34, 17));
  25. this.addSlotToContainer(new Slot(playerInv, 1, 34, 35));
  26. this.addSlotToContainer(new Slot(playerInv, 1, 34, 54));
  27.  
  28. this.addSlotToContainer(new Slot(playerInv, 1, 126, 17));
  29. this.addSlotToContainer(new Slot(playerInv, 1, 126, 35));
  30. this.addSlotToContainer(new Slot(playerInv, 1, 126, 54));
  31.  
  32. //Output
  33. this.addSlotToContainer(new Slot(playerInv, 1, 80, 35));
  34.  
  35. }
  36. }
  37.  
  38. for (j = 0; j < 9; ++j) {
  39. this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 160 + i));
  40. }
  41. }
  42.  
  43.  
  44. public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
  45. ItemStack itemstack = null;
  46. Slot slot = (Slot)this.inventorySlots.get(index);
  47.  
  48. if (slot != null && slot.getHasStack()) {
  49. ItemStack itemstack1 = slot.getStack();
  50. itemstack = itemstack1.copy();
  51.  
  52. if (index < 27) {
  53. if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true)) {
  54. return null;
  55. }
  56. }
  57. else if(!this.mergeItemStack(itemstack1, 0, 27, false)) {
  58. return null;
  59. }
  60.  
  61. if (itemstack1.stackSize == 0) {
  62. slot.putStack((ItemStack)null);
  63. }
  64. else {
  65. slot.onSlotChanged();
  66. }
  67. }
  68.  
  69. return itemstack;
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement