@Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = (Slot) inventorySlots.get(slot);
    int machInvSize = _ncw.getSizeInventory();

    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      stack = stackInSlot.copy();

      if (slot < machInvSize) {
        if (!mergeItemStack(stackInSlot, machInvSize, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(stackInSlot, 0, machInvSize, false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slotObject.putStack(null);
      } else {
        slotObject.onSlotChanged();
      }

      if (stackInSlot.stackSize == stack.stackSize) {
        return null;
      }

      slotObject.onPickupFromSlot(player, stackInSlot);
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = (Slot) inventorySlots.get(slot);

    // null checks and checks if the item can be stacked (maxStackSize > 1)
    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      stack = stackInSlot.copy();

      // merges the item into player inventory since its in the tileEntity
      if (slot < 9) {
        if (!this.mergeItemStack(stackInSlot, 0, 35, true)) {
          return null;
        }
      }
      // places it into the tileEntity is possible since its in the player inventory
      else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slotObject.putStack(null);
      } else {
        slotObject.onSlotChanged();
      }

      if (stackInSlot.stackSize == stack.stackSize) {
        return null;
      }
      slotObject.onPickupFromSlot(player, stackInSlot);
    }
    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    ItemStack itemstack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if ((slotIndex < 0 || slotIndex > 2) && slotIndex != 3) {
        if (!ingredientSlot.getHasStack() && ingredientSlot.isItemValid(itemstack1)) {
          if (!mergeItemStack(itemstack1, 3, 4, false)) return null;
        } else if (PotionSlot.canHoldPotion(itemstack)) {
          if (!mergeItemStack(itemstack1, 0, 3, false)) return null;
        } else if (slotIndex >= 4 && slotIndex < 31) {
          if (!mergeItemStack(itemstack1, 31, 40, false)) return null;
        } else if (slotIndex >= 31 && slotIndex < 40) {
          if (!mergeItemStack(itemstack1, 4, 31, false)) return null;
        } else if (!mergeItemStack(itemstack1, 4, 40, false)) return null;
      } else {
        if (!mergeItemStack(itemstack1, 4, 40, true)) return null;

        slot.onSlotChange(itemstack1, itemstack);
      }

      if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null);
      else slot.onSlotChanged();

      if (itemstack1.stackSize == itemstack.stackSize) return null;

      slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
  }
Пример #4
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 0) {
        if (!this.mergeItemStack(itemstack1, 1, 37, true)) {
          return null;
        }
      } else if (par2 != 0) {
        if (par2 >= 1 && par2 < 37) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return null;
          }
        }
      }
      slot.onSlotChanged();
      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
Пример #5
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack itemstack = null;
    Slot slot = this.inventorySlots.get(slotID);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (slotID == 2) {
        if (!this.mergeItemStack(itemstack1, 3, 39, true)) return null;

        slot.onSlotChange(itemstack1, itemstack);
      } else if (slotID != 1 && slotID != 0) {
        if (TileScribe.isValidForScribe(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) return null;
        } else if (TileScribe.isBook(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 1, 2, false)) return null;
        } else if (slotID >= 3 && slotID < 30) {
          if (!this.mergeItemStack(itemstack1, 30, 39, false)) return null;
        } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
          return null;
      } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) return null;

      if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null);
      else slot.onSlotChanged();

      if (itemstack1.stackSize == itemstack.stackSize) return null;

      slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
  }
Пример #6
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int index) {
    Slot slot = getSlot(index);
    if (!this.getSlot(currentSlot).getHasStack()) return null;

    if (slot != null && slot.getHasStack()) {
      ItemStack stack = slot.getStack();
      ItemStack result = stack.copy();
      if (index >= 9) { // To player
        if (!mergeItemStack(stack, 0, 9, false)) {
          return null;
        }
      } else {
        return null;
      }

      if (stack.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }

      slot.onPickupFromSlot(player, stack);

      return result;
    }

    return null;
  }
Пример #7
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot currentSlot = (Slot) inventorySlots.get(slotID);

    if (currentSlot != null && currentSlot.getHasStack()) {
      ItemStack slotStack = currentSlot.getStack();
      stack = slotStack.copy();

      if (slotID < 27) {
        if (!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(slotStack, 0, 27, false)) {
        return null;
      }

      if (slotStack.stackSize == 0) {
        currentSlot.putStack((ItemStack) null);
      } else {
        currentSlot.onSlotChanged();
      }

      if (slotStack.stackSize == stack.stackSize) {
        return null;
      }

      currentSlot.onPickupFromSlot(player, slotStack);
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int par2) {

    ItemStack itemstack = null;
    Slot slot = (Slot) inventorySlots.get(par2);
    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();
      if (par2 >= 9 && par2 < 18) {
        if (!mergeItemStack(itemstack1, 27, 63, true)) return null;
      } else if (par2 >= 27 && !mergeItemStack(itemstack1, 9, 18, false)) {
        return null;
      }
      if (itemstack1.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
      if (itemstack1.stackSize != itemstack.stackSize) {
        slot.onPickupFromSlot(player, itemstack1);
      } else {
        return null;
      }
    }
    return itemstack;
  }
    @Override
    public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
      if (stack.getItem() instanceof ItemPotion && stack.getItemDamage() > 0)
        player.addStat(AchievementList.potion, 1);

      super.onPickupFromSlot(player, stack);
    }
Пример #10
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    if (slotIndex == 0) {
      return null;
    }

    Slot slot = this.getSlot(slotIndex);

    if (slot == null || !slot.getHasStack()) {
      return null;
    }

    ItemStack stack = slot.getStack();
    ItemStack newStack = stack.copy();

    if (slotIndex <= 91) {
      if (!this.mergeItemStack(stack, 92, 127, false)) {
        return null;
      }
    } else if (!EMCHelper.doesItemHaveEmc(stack) || !this.mergeItemStack(stack, 1, 91, false)) {
      return null;
    }

    if (stack.stackSize == 0) {
      slot.putStack(null);
    } else slot.onSlotChanged();
    slot.onPickupFromSlot(player, stack);
    return newStack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = inventorySlots.get(slot);

    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      stack = stackInSlot.copy();

      if (slot < slotCount) {
        if (!this.mergeItemStack(stackInSlot, slotCount, (slotCount + 36), true)) return null;
      } else {
        boolean b = false;
        for (int i = 0; i < slotCount; i++)
          if (this.getSlot(i).isItemValid(stackInSlot))
            if (this.mergeItemStack(stackInSlot, i, i + 1, false)) {
              b = true;
              break;
            }
        if (!b) return null;
      }

      if (stackInSlot.stackSize == 0) slotObject.putStack(null);
      else slotObject.onSlotChanged();

      if (stackInSlot.stackSize == stack.stackSize) return null;
      slotObject.onPickupFromSlot(player, stackInSlot);
    }
    return stack;
  }
Пример #12
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int clickedIndex) {
    ItemStack returnedStack = null;
    Slot clickedSlot = (Slot) this.inventorySlots.get(clickedIndex);

    if (clickedSlot != null
        && clickedSlot.getHasStack()
        && (clickedSlot.getStack().getItem() instanceof IFood
            || clickedSlot.getStack().itemID == Item.bowlEmpty.itemID)) {
      ItemStack clickedStack = clickedSlot.getStack();
      returnedStack = clickedStack.copy();

      if (clickedIndex < 6) {
        if (!this.mergeItemStack(clickedStack, 6, inventorySlots.size(), true)) return null;
      } else if (clickedIndex >= 6 && clickedIndex < inventorySlots.size()) {
        if (!this.mergeItemStack(clickedStack, 0, 6, false)) return null;
      } else if (!this.mergeItemStack(clickedStack, 6, inventorySlots.size(), false)) return null;

      if (clickedStack.stackSize == 0) clickedSlot.putStack((ItemStack) null);
      else clickedSlot.onSlotChanged();

      if (clickedStack.stackSize == returnedStack.stackSize) return null;
      clickedSlot.onPickupFromSlot(player, clickedStack);
    }
    return returnedStack;
  }
 private ItemStack slotClickPhantom(
     Slot slot, int mouseButton, int modifier, EntityPlayer player) {
   ItemStack stack = null;
   if (mouseButton == 2) {
     if (((IPhantomSlot) slot).canAdjust()) slot.putStack(null);
   } else if (mouseButton == 0 || mouseButton == 1) {
     InventoryPlayer playerInv = player.inventory;
     slot.onSlotChanged();
     ItemStack stackSlot = slot.getStack();
     ItemStack stackHeld = playerInv.getItemStack();
     if (stackSlot != null) stack = stackSlot.copy();
     if (stackSlot == null) {
       if (stackHeld != null && slot.isItemValid(stackHeld))
         fillPhantomSlot(slot, stackHeld, mouseButton);
     } else if (stackHeld == null) {
       adjustPhantomSlot(slot, mouseButton, modifier);
       slot.onPickupFromSlot(player, playerInv.getItemStack());
     } else if (slot.isItemValid(stackHeld)) {
       if (ItemUtil.canStacksMerge(stackSlot, stackHeld))
         adjustPhantomSlot(slot, mouseButton, modifier);
       else fillPhantomSlot(slot, stackHeld, mouseButton);
     }
   }
   return stack;
 }
Пример #14
0
 @Override
 public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i) {
   ItemStack itemstack = null;
   Slot slot = (Slot) inventorySlots.get(i);
   if (slot != null && slot.getHasStack()) {
     ItemStack itemstack1 = slot.getStack();
     itemstack = itemstack1.copy();
     if (i == 0) {
       if (!mergeItemStack(itemstack1, 10, 46, true)) {
         return null;
       }
     } else if (i >= 10 && i < 37) {
       if (!mergeItemStack(itemstack1, 37, 46, false)) {
         return null;
       }
     } else if (i >= 37 && i < 46) {
       if (!mergeItemStack(itemstack1, 10, 37, false)) {
         return null;
       }
     } else if (!mergeItemStack(itemstack1, 10, 46, false)) {
       return null;
     }
     if (itemstack1.stackSize == 0) {
       slot.putStack(null);
     } else {
       slot.onSlotChanged();
     }
     if (itemstack1.stackSize != itemstack.stackSize) {
       slot.onPickupFromSlot(entityplayer, itemstack1);
     } else {
       return null;
     }
   }
   return itemstack;
 }
Пример #15
0
 @Override
 public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
   ItemStack result = null;
   Slot slot = getSlot(slotIndex);
   if (slot != null && slot.getHasStack()) {
     ItemStack stack = slot.getStack();
     result = stack.copy();
     if (slotIndex == 1) {
       if (!mergeItemStack(stack, 2, 38, true)) return null;
       slot.onSlotChange(stack, result);
     } else if (slotIndex != 0) {
       if (FurnaceRecipes.smelting().getSmeltingResult(stack) != null) {
         if (!this.mergeItemStack(stack, 0, 1, false)) return null;
       } else if (slotIndex >= 2 && slotIndex < 29) {
         if (!this.mergeItemStack(stack, 29, 38, false)) return null;
       } else if (slotIndex >= 29 && slotIndex < 38) {
         if (!this.mergeItemStack(stack, 2, 29, false)) return null;
       }
     } else if (!this.mergeItemStack(stack, 2, 38, false)) return null;
     if (stack.stackSize <= 0) slot.putStack(null);
     else slot.onSlotChanged();
     if (stack.stackSize == result.stackSize) return null;
     slot.onPickupFromSlot(player, stack);
   }
   return result;
 }
Пример #16
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    Slot var4 = (Slot) this.inventorySlots.get(par2);

    if (var4 != null && var4.getHasStack()) {
      ItemStack var5 = var4.getStack();
      var3 = var5.copy();

      if (par2 == 2) {
        if (!this.mergeItemStack(var5, 3, 39, true)) return null;

        var4.onSlotChange(var5, var3);
      } else if (par2 != 0 && par2 != 1) {
        if (par2 >= 3 && par2 < 30) {
          if (!this.mergeItemStack(var5, 30, 39, false)) return null;
        } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false)) return null;
      } else if (!this.mergeItemStack(var5, 3, 39, false)) return null;

      if (var5.stackSize == 0) {
        var4.putStack((ItemStack) null);
      } else {
        var4.onSlotChanged();
      }

      if (var5.stackSize == var3.stackSize) return null;

      var4.onPickupFromSlot(par1EntityPlayer, var5);
    }

    return var3;
  }
Пример #17
0
 public ItemStack getStackInSlot(int i) {
   ItemStack itemstack = null;
   Slot slot = (Slot) this.inventorySlots.get(i);
   if (slot != null && slot.getHasStack()) {
     ItemStack itemstack1 = slot.getStack();
     itemstack = itemstack1.copy();
     if (i == 0) {
       this.mergeItemStack(itemstack1, 9, 45, true);
     } else if (i >= 9 && i < 36) {
       this.mergeItemStack(itemstack1, 36, 45, false);
     } else if (i >= 36 && i < 45) {
       this.mergeItemStack(itemstack1, 9, 36, false);
     } else {
       this.mergeItemStack(itemstack1, 9, 45, false);
     }
     if (itemstack1.stackSize == 0) {
       slot.putStack(null);
     } else {
       slot.onSlotChanged();
     }
     if (itemstack1.stackSize != itemstack.stackSize) {
       slot.onPickupFromSlot(
           null, // Entityplayer
           itemstack1);
     } else {
       return null;
     }
   }
   return itemstack;
 }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    int size = ((IInventory) tile).getSizeInventory();
    int low = size + 27;
    int high = low + 9;
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotID);

    if (slot != null && slot.getHasStack()) {
      ItemStack stack = slot.getStack();
      itemstack = stack.copy();

      if (slotID < size) {
        if (!this.mergeItemStack(stack, size, high, true)) {
          return null;
        }

        slot.onSlotChange(stack, itemstack);
      } else if (slotID >= size) {
        if (itemstack.getItem() == Factory.fludd) {
          if (!this.mergeItemStack(stack, 5, 6, false)) { // Slot 0-0
            return null;
          }
        } else if (stack.getItem() instanceof IItemUpgrade) {
          if (!this.mergeItemStack(stack, 0, 3, false)) { // Slot 1-3
            return null;
          }
        } else if (FluidHelper.isFluidOrEmpty(stack)) {
          if (!this.mergeItemStack(stack, 3, 4, false)) { // Slot 3-3
            return null;
          }
        } else if (slotID >= size && slotID < low) {
          if (!this.mergeItemStack(stack, low, high, false)) {
            return null;
          }
        } else if (slotID >= low
            && slotID < high
            && !this.mergeItemStack(stack, high, low, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(stack, size, high, false)) {
        return null;
      }

      if (stack.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (stack.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(player, stack);
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    ItemStack originalStack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack stack = slot.getStack();
      originalStack = stack.copy();

      if (slotIndex == 2) {
        if (!mergeItemStack(stack, 3, 39, true)) {
          return null;
        }

        slot.onSlotChange(stack, originalStack);
      } else if (slotIndex > 1) {
        boolean inserted = false;

        for (int i = 1; i >= 0; i--) {
          if (campfireEnt.canInsertItem(i, stack, 0)) {
            inserted = true;

            if (!mergeItemStack(stack, i, i + 1, false)) {
              return null;
            }

            break;
          }
        }

        if (!inserted) {
          if (slotIndex >= 3 && slotIndex < 30) // Player inventory
          {
            if (!mergeItemStack(stack, 30, 39, false)) {
              return null;
            }
          } else if (slotIndex >= 30 && slotIndex < 39 && !mergeItemStack(stack, 3, 30, false)) {
            return null;
          }
        }
      } else if (!mergeItemStack(stack, 3, 39, false)) {
        return null;
      }

      if (stack.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }

      if (stack.stackSize == originalStack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(player, stack);
    }

    return originalStack;
  }
  // Shfit-click handling
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int sourceSlotId) {
    ItemStack transferedItemStack = null;
    Slot slot = this.getSlot(sourceSlotId);

    if (slot == null || !slot.getHasStack()) {
      return transferedItemStack;
    }

    ItemStack slotStack = slot.getStack();
    transferedItemStack = slotStack.copy();

    if (sourceSlotId == 2) {
      // source is output slot
      if (!mergeItemStack(slotStack, 3, 39, true)) {
        return null;
      }

      slot.onSlotChange(slotStack, transferedItemStack);
    } else if (sourceSlotId != 0 && sourceSlotId != 1) {
      // source is player inventory
      if (RecipesAbstractor.getBaseEssence(slotStack) > 0) {
        if (!mergeItemStack(slotStack, 1, 2, false)) {
          return null;
        }
      } else if (RecipesAbstractor.getCatalystBurning(slotStack) > 0) {
        if (!mergeItemStack(slotStack, 0, 1, false)) {
          return null;
        }
      } else if (sourceSlotId >= 3 && sourceSlotId < 30) {
        // source is from player non-hotbar slots
        if (!mergeItemStack(slotStack, 30, 39, false)) {
          return null;
        }
      } else if (sourceSlotId >= 30 && sourceSlotId < 39) {
        // source is from player hotbar slots
        if (!mergeItemStack(slotStack, 3, 30, false)) {
          return null;
        }
      }

    } else if (!mergeItemStack(slotStack, 3, 39, false)) {
      return null;
    }

    if (slotStack.stackSize <= 0) {
      slot.putStack(null);
    } else {
      slot.onSlotChanged();
    }

    if (transferedItemStack.stackSize == slotStack.stackSize) {
      return null;
    }

    slot.onPickupFromSlot(player, slotStack);

    return transferedItemStack;
  }
Пример #21
0
  /** Take a stack from the specified inventory slot. */
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    Slot var4 = (Slot) this.inventorySlots.get(par2);

    if (var4 != null && var4.getHasStack()) {
      ItemStack var5 = var4.getStack();
      var3 = var5.copy();

      if (par2 == 0) {
        if (!this.mergeItemStack(var5, 9, 45, true)) {
          return null;
        }

        var4.onSlotChange(var5, var3);
      } else if (par2 >= 1 && par2 < 5) {
        if (!this.mergeItemStack(var5, 9, 45, false)) {
          return null;
        }
      } else if (par2 >= 5 && par2 < 9) {
        if (!this.mergeItemStack(var5, 9, 45, false)) {
          return null;
        }
      } else if (var3.getItem() instanceof ItemArmor
          && !((Slot) this.inventorySlots.get(5 + ((ItemArmor) var3.getItem()).armorType))
              .getHasStack()) {
        int var6 = 5 + ((ItemArmor) var3.getItem()).armorType;

        if (!this.mergeItemStack(var5, var6, var6 + 1, false)) {
          return null;
        }
      } else if (par2 >= 9 && par2 < 36) {
        if (!this.mergeItemStack(var5, 36, 45, false)) {
          return null;
        }
      } else if (par2 >= 36 && par2 < 45) {
        if (!this.mergeItemStack(var5, 9, 36, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(var5, 9, 45, false)) {
        return null;
      }

      if (var5.stackSize == 0) {
        var4.putStack((ItemStack) null);
      } else {
        var4.onSlotChanged();
      }

      if (var5.stackSize == var3.stackSize) {
        return null;
      }

      var4.onPickupFromSlot(par1EntityPlayer, var5);
    }

    return var3;
  }
  /**
   * Called when a player shift-clicks on a slot. You must override this or you will crash when
   * someone does that.
   */
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 0) {
        if (!this.mergeItemStack(itemstack1, 9, 45, true)) {
          return null;
        }

        slot.onSlotChange(itemstack1, itemstack);
      } else if (par2 >= 1 && par2 < 5) {
        if (!this.mergeItemStack(itemstack1, 9, 45, false)) {
          return null;
        }
      } else if (par2 >= 5 && par2 < 9) {
        if (!this.mergeItemStack(itemstack1, 9, 45, false)) {
          return null;
        }
      } else if (itemstack.getItem() instanceof ItemArmor
          && !((Slot) this.inventorySlots.get(5 + ((ItemArmor) itemstack.getItem()).armorType))
              .getHasStack()) {
        int j = 5 + ((ItemArmor) itemstack.getItem()).armorType;

        if (!this.mergeItemStack(itemstack1, j, j + 1, false)) {
          return null;
        }
      } else if (par2 >= 9 && par2 < 36) {
        if (!this.mergeItemStack(itemstack1, 36, 45, false)) {
          return null;
        }
      } else if (par2 >= 36 && par2 < 45) {
        if (!this.mergeItemStack(itemstack1, 9, 36, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(itemstack1, 9, 45, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (itemstack1.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
 /**
  * Called when a player shift-clicks on a slot. You must override this or you will crash when
  * someone does that.
  */
 @Override
 public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int iSlot) {
   ItemStack itemstack = null;
   Slot slot = (Slot) this.inventorySlots.get(iSlot);
   int playerStart = 36,
       playerEnd = 63,
       topStart = 4,
       topEnd = 36,
       hotbarStart = 63,
       hotbarEnd = 72,
       armorStart = 0,
       armorEnd = 4;
   // 36 to 62 is lower
   // 4 to 40 is bottom
   if (slot != null && slot.getHasStack()) {
     ItemStack copy = slot.getStack();
     itemstack = copy.copy();
     if (itemstack.getItem() instanceof ItemArmor) {
       // ItemArmor armor = (ItemArmor) copy.getItem();
       // int armorSlot = 8 - armor.armorType.getIndex();
       // if (!this.mergeItemStack(copy, armorSlot, armorSlot + 1, false)) { return null; }
       if (armorStart <= iSlot && iSlot < armorEnd) {
         if (!this.mergeItemStack(copy, playerStart, playerEnd, false)) {
           return null;
         }
       } else {
         if (!this.mergeItemStack(copy, 0, 4, false)) {
           return null;
         }
       }
     } else if (playerStart <= iSlot && iSlot < playerEnd) {
       if (!this.mergeItemStack(copy, topStart, topEnd, false)) {
         return null;
       }
     } else if (topStart <= iSlot && iSlot < topEnd) {
       if (!this.mergeItemStack(copy, playerStart, playerEnd, false)) {
         return null;
       }
     } else if (hotbarStart <= iSlot && iSlot < hotbarEnd) {
       if (!this.mergeItemStack(copy, topStart, topEnd, false)) {
         return null;
       }
     }
     if (copy.stackSize == 0) {
       slot.putStack((ItemStack) null);
     } else {
       slot.onSlotChanged();
     }
     if (copy.stackSize == itemstack.stackSize) {
       return null;
     }
     slot.onPickupFromSlot(par1EntityPlayer, copy);
   }
   return itemstack;
 }
  public ItemStack transferStackInSlot(EntityPlayer player, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 < INV_START) {
        if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END, true)) {
          return null;
        }

        slot.onSlotChange(itemstack1, itemstack);
      } else {
        int current = this.getCurrentUsage();
        if (par2 >= INV_START && (current == 0 || current == 1)) {
          if (!this.mergeItemStack(itemstack1, 0, 2, false)) {
            return null;
          }
        } else if (par2 >= INV_START && current == 2) {
          if (!this.mergeItemStack(itemstack1, 3, 5, false)) {
            return null;
          }
        } else if (par2 >= INV_START && current == 3) {
          if (!this.mergeItemStack(itemstack1, 6, 9, false)) {
            return null;
          }
        } else if (par2 >= INV_START && par2 < HOTBAR_START) {
          if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END, false)) {
            return null;
          }
        } else if (par2 >= HOTBAR_START && par2 < HOTBAR_END) {
          if (!this.mergeItemStack(itemstack1, INV_START, INV_END, false)) {
            return null;
          }
        }
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (itemstack1.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
  }
Пример #25
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack temp = slot.getStack();
      itemstack = temp.copy();

      if (slotIndex == 3) {
        if (!this.mergeItemStack(temp, 3, 39, true)) {
          return null;
        }

        slot.onSlotChange(temp, itemstack);
      } else if (slotIndex != 0 && slotIndex != 1 && slotIndex != 2) {
        if (temp.getItem().getItemEnchantability() > 0) {
          if (!this.mergeItemStack(temp, 0, 1, false)) {
            return null;
          }
        } else if (temp.itemID == MabiCraftItem.itemEnchantScroll.itemID) {
          if (!this.mergeItemStack(temp, 1, 2, false)) {
            return null;
          }
        } else if (temp.itemID == MabiCraftItem.itemMagicPowder.itemID) {
          if (!this.mergeItemStack(temp, 2, 3, false)) {
            return null;
          }
        } else if (slotIndex >= 4 && slotIndex < 31) {
          if (!this.mergeItemStack(temp, 31, 40, false)) {
            return null;
          }
        } else if (slotIndex >= 31 && slotIndex < 40 && !this.mergeItemStack(temp, 4, 31, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(temp, 4, 40, false)) {
        return null;
      }

      if (temp.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (temp.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, temp);
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
    ItemStack var2 = null;
    Slot var3 = (Slot) this.inventorySlots.get(par1);

    if (var3 != null && var3.getHasStack()) {
      ItemStack var4 = var3.getStack();
      var2 = var4.copy();

      if (par1 == 0) {
        if (!this.mergeItemStack(var4, 1, 37, true)) {
          return null;
        }

        var3.onSlotChange(var4, var2);
      } else if (par1 != 1 && par1 != 0) {
        if (var4.getItem() instanceof IItemElectric) {
          Slot temp = (Slot) this.inventorySlots.get(0);
          if (!temp.getHasStack()) {
            temp.putStack(var4);
            var3.decrStackSize(1);
          }
          if (!this.mergeItemStack(var4, 0, 0, false)) {
            return null;
          }
        } else if (par1 >= 1 && par1 < 28) {
          if (!this.mergeItemStack(var4, 32, 40, false)) {
            return null;
          }
        } else if (par1 >= 32 && par1 < 40 && !this.mergeItemStack(var4, 3, 30, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(var4, 4, 31, false)) {
        return null;
      }

      if (var4.stackSize == 0) {
        var3.putStack((ItemStack) null);
      } else {
        var3.onSlotChanged();
      }

      if (var4.stackSize == var2.stackSize) {
        return null;
      }

      var3.onPickupFromSlot(par1EntityPlayer, var4);
    }

    return var2;
  }
  /** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
    ItemStack var2 = null;
    final Slot var3 = (Slot) inventorySlots.get(par1);

    if (var3 != null && var3.getHasStack()) {
      final ItemStack var4 = var3.getStack();
      var2 = var4.copy();

      if (par1 == 1) {
        if (!mergeItemStack(var4, 2, 38, true)) {
          return null;
        }

        var3.onSlotChange(var4, var2);
      } else if (par1 != 1 && par1 != 0) {
        if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null) {
          if (!mergeItemStack(var4, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityFurnace.isItemFuel(var4)) {
          if (!mergeItemStack(var4, 0, 1, false)) {
            return null;
          }
        } else if (par1 >= 2 && par1 < 29) {
          if (!mergeItemStack(var4, 29, 38, false)) {
            return null;
          }
        } else if (par1 >= 29 && par1 < 38 && !mergeItemStack(var4, 2, 29, false)) {
          return null;
        }
      } else if (!mergeItemStack(var4, 2, 38, false)) {
        return null;
      }

      if (var4.stackSize == 0) {
        var3.putStack((ItemStack) null);
      } else {
        var3.onSlotChanged();
      }

      if (var4.stackSize == var2.stackSize) {
        return null;
      }

      var3.onPickupFromSlot(par1EntityPlayer, var4);
    }

    return var2;
  }
Пример #28
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot currentSlot = (Slot) inventorySlots.get(slotID);

    if (currentSlot != null && currentSlot.getHasStack()) {
      ItemStack slotStack = currentSlot.getStack();
      stack = slotStack.copy();

      if (FluidContainerUtils.isFluidContainer(slotStack)) {
        if (slotID != 0 && slotID != 1) {
          if (!mergeItemStack(slotStack, 0, 1, false)) {
            return null;
          }
        } else {
          if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) {
            return null;
          }
        }
      } else {
        if (slotID >= 2 && slotID <= 28) {
          if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) {
            return null;
          }
        } else if (slotID > 28) {
          if (!mergeItemStack(slotStack, 2, 28, false)) {
            return null;
          }
        } else {
          if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) {
            return null;
          }
        }
      }

      if (slotStack.stackSize == 0) {
        currentSlot.putStack((ItemStack) null);
      } else {
        currentSlot.onSlotChanged();
      }

      if (slotStack.stackSize == stack.stackSize) {
        return null;
      }

      currentSlot.onPickupFromSlot(player, slotStack);
    }

    return stack;
  }
  /**
   * Called when a player shift-clicks on a slot. You must override this or you will crash when
   * someone does that.
   */
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 2) {
        if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
          return null;
        }

        slot.onSlotChange(itemstack1, itemstack);
      } else if (par2 != 1 && par2 != 0) {
        if (ConcreteMixerRecipes.smelting().getSmeltingResult(itemstack1) != null) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityConcreteMixer.isItemFuel(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
            return null;
          }
        } else if (par2 >= 3 && par2 < 30) {
          if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
            return null;
          }
        } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
          return null;
        }
      } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (itemstack1.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
    ItemStack var2 = null;
    final Slot slot = (Slot) this.inventorySlots.get(par1);
    final int b = this.inventorySlots.size();

    if (slot != null && slot.getHasStack()) {
      final ItemStack stack = slot.getStack();
      var2 = stack.copy();

      if (par1 < 2) {
        if (!this.mergeItemStack(stack, b - 36, b, true)) {
          return null;
        }
      } else {
        if (stack.getItem() instanceof IItemElectric) {
          if (!this.mergeItemStack(stack, 0, 1, false)) {
            return null;
          }
        } else if (stack.getItem() instanceof IItemOxygenSupply) {
          if (!this.mergeItemStack(stack, 1, 2, false)) {
            return null;
          }
        } else {
          if (par1 < b - 9) {
            if (!this.mergeItemStack(stack, b - 9, b, false)) {
              return null;
            }
          } else if (!this.mergeItemStack(stack, b - 36, b - 9, false)) {
            return null;
          }
        }
      }

      if (stack.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (stack.stackSize == var2.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, stack);
    }

    return var2;
  }