Advertisement
Guest User

InventorySubCraft

a guest
Jul 4th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. package simcraft.machines;
  2.  
  3. import net.minecraft.inventory.Container;
  4. import net.minecraft.inventory.IInventory;
  5. import net.minecraft.inventory.InventoryCrafting;
  6. import net.minecraft.item.ItemStack;
  7.  
  8. public class InventorySubCraft extends InventoryCrafting
  9. {
  10. private Container eventHandler;
  11. private IInventory parent;
  12.  
  13.  
  14.  
  15. public InventorySubCraft(Container var1, IInventory var2)
  16. {
  17. super(var1, 3, 3);
  18. this.parent = var2;
  19. this.eventHandler = var1;
  20. }
  21.  
  22. /**
  23. * Returns the number of slots in the inventory.
  24. */
  25. public int getSizeInventory()
  26. {
  27. return 9;
  28. }
  29.  
  30. /**
  31. * Returns the stack in slot i
  32. */
  33. public ItemStack getStackInSlot(int var1)
  34. {
  35. return var1 >= this.getSizeInventory() ? null : this.parent.getStackInSlot(var1);
  36. }
  37.  
  38. /**
  39. * Returns the itemstack in the slot specified (Top left is 0, 0). Args: row, column
  40. */
  41. public ItemStack getStackInRowAndColumn(int var1, int var2)
  42. {
  43. if (var1 >= 0 && var1 < 3)
  44. {
  45. int var3 = var1 + var2 * 3;
  46. return this.getStackInSlot(var3);
  47. }
  48. else
  49. {
  50. return null;
  51. }
  52. }
  53.  
  54.  
  55. /**
  56. * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
  57. * stack.
  58. */
  59. public ItemStack decrStackSize(int var1, int var2)
  60. {
  61. ItemStack var3 = this.parent.decrStackSize(var1, var2);
  62.  
  63. if (var3 != null)
  64. {
  65. this.eventHandler.onCraftMatrixChanged(this);
  66. }
  67.  
  68. return var3;
  69. }
  70.  
  71. /**
  72. * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
  73. */
  74. public void setInventorySlotContents(int var1, ItemStack var2)
  75. {
  76. this.parent.setInventorySlotContents(var1, var2);
  77. this.eventHandler.onCraftMatrixChanged(this);
  78. }
  79.  
  80. /**
  81. * Called when an the contents of an Inventory change, usually
  82. */
  83. public void onInventoryChanged() {}
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement