Advertisement
downwind

Untitled

Dec 16th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.89 KB | None | 0 0
  1. public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
  2.     {
  3.         ItemStack itemstack = null;
  4.         Slot slot = (Slot) this.inventorySlots.get(slotIndex);
  5.  
  6.         if (slot != null && slot.getHasStack()) {
  7.             ItemStack itemstack1 = slot.getStack();
  8.             itemstack = itemstack1.copy();
  9.  
  10.             // If item is in TileEntity inventory
  11.             if (slotIndex >= INPUT_CONCRETE_1 && slotIndex <= INPUT_MODIFIER_2 && slotIndex < INV_START) {
  12.                 // try to place in player inventory / action bar
  13.                 if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, false)) {
  14.                     return null;
  15.                 }
  16.                 slot.onSlotChange(itemstack1, itemstack);
  17.             }
  18.             // Item is in player inventory, try to place in GUI
  19.             else if (slotIndex < HOTBAR_END) {
  20.                 // if it's concrete put in Concrete slot
  21.                 //   if (itemstack1.isItemEqual(new ItemStack(ModBlocks.concrete))) {
  22.                 if (BlockTableRecipes.isCraftableBlock(itemstack1)) {
  23.                     if (!this.mergeItemStack(itemstack1, INPUT_CONCRETE_1, INPUT_CONCRETE_1 + 1, false)) {
  24.                         return null;
  25.                     }
  26.                 }
  27.                 // if it is a recipe material, place in the Modifier input slot
  28.                 else if (BlockTableRecipes.isMaterial(itemstack1)) {
  29.                     if (!this.mergeItemStack(itemstack1, INPUT_MODIFIER_2, INPUT_MODIFIER_2 + 1, false)) {
  30.                         return null;
  31.                     }
  32.                 }
  33.                 // item in player's inventory, but not in action bar
  34.                 else if (slotIndex >= INV_START && slotIndex < HOTBAR_START) {
  35.                     // place in action bar
  36.                     if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) {
  37.                         return null;
  38.                     }
  39.                 }
  40.                 // item in action bar - place in player inventory
  41.                 else if (slotIndex >= HOTBAR_START && slotIndex < HOTBAR_END + 1 && !this.mergeItemStack(itemstack1, INV_START, HOTBAR_START, false)) {
  42.                     return null;
  43.                 }
  44.             }
  45.             // In one of the slots; try to place in player inventory / action bar
  46.             else if (slotIndex >= INPUT_CONCRETE_1 && slotIndex <= INPUT_MODIFIER_2 && !this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, false)) {
  47.                 return null;
  48.             }
  49.             if (itemstack1.stackSize == 0) {
  50.                 slot.putStack((ItemStack) null);
  51.             } else {
  52.                 slot.onSlotChanged();
  53.             }
  54.             if (itemstack1.stackSize == itemstack.stackSize) {
  55.                 return null;
  56.             }
  57.             slot.onPickupFromSlot(player, itemstack1);
  58.         }
  59.         return itemstack;
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement