@Override
  public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer player) {
    Slot slot = id < 0 ? null : this.inventorySlots.get(id);
    if (!(slot instanceof IESlot.Ghost)) return super.slotClick(id, button, clickType, player);
    // Spooky Ghost Slots!!!!
    ItemStack stack = null;
    ItemStack stackSlot = slot.getStack();
    if (stackSlot != null) stack = stackSlot.copy();

    if (button == 2) slot.putStack(null);
    else if (button == 0 || button == 1) {
      InventoryPlayer playerInv = player.inventory;
      ItemStack stackHeld = playerInv.getItemStack();
      if (stackSlot == null) {
        if (stackHeld != null && slot.isItemValid(stackHeld)) {
          slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
        }
      } else if (stackHeld == null) {
        slot.putStack(null);
      } else if (slot.isItemValid(stackHeld)) {
        slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
      }
    } else if (button == 5) {
      InventoryPlayer playerInv = player.inventory;
      ItemStack stackHeld = playerInv.getItemStack();
      if (!slot.getHasStack()) {
        slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
      }
    }
    return stack;
  }
  @Override
  public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
    if (!world.isRemote) {
      if (this.isAbsorbingFocillium) {
        if (getForceciumlevel(itemStack) < getMaxForceciumlevel()) {
          if ((entity instanceof EntityPlayer)) {
            List<Slot> slots = ((EntityPlayer) entity).inventoryContainer.inventorySlots;
            for (Slot slot : slots) {
              if ((slot.getStack() != null)
                  && (slot.getStack().getItem() == ModularForceFieldSystem.itemForcicium)) {
                setForceciumlevel(itemStack, getForceciumlevel(itemStack) + 1);

                if (slot.getStack().stackSize > 1) {
                  ItemStack forcecium =
                      new ItemStack(
                          ModularForceFieldSystem.itemForcicium, slot.getStack().stackSize - 1);
                  slot.putStack(forcecium);
                  break;
                }
                slot.putStack(null);

                break;
              }
            }
          }
        }

        itemStack.setItemDamage(getItemDamage(itemStack));
      }
    }
  }
  /** Updates the slots to reflect the stored patterns. */
  private void updatePatternSlots() {
    Iterator<ItemStack> iterator = null;

    // Get the list of stored pattern results
    if (this.kCoreHandler.hasCore()) {
      ArrayList<ItemStack> storedResults = this.kCoreHandler.getStoredOutputs();
      iterator = storedResults.iterator();
    }

    // Loop over all pattern slots
    for (Slot patternSlot : this.patternSlots) {
      // Is there an itemstack to put?
      if ((iterator != null) && (iterator.hasNext())) {
        // Put the result
        patternSlot.putStack(iterator.next());
      } else {
        // Clear the slot
        patternSlot.putStack(null);
      }

      // Update clients with change
      for (int cIndex = 0; cIndex < this.crafters.size(); ++cIndex) {
        ((ICrafting) this.crafters.get(cIndex))
            .sendSlotContents(this, patternSlot.slotNumber, patternSlot.getStack());
      }
    }
  }
Exemplo n.º 4
0
  public ItemStack handle(EntityPlayer player, int mouseButton, Slot slot) {
    if (mouseButton > 0) {
      slot.putStack(null);
    } else if (mouseButton == 0) {
      ItemStack stack;
      InventoryPlayer playerInv = player.inventory;
      slot.onSlotChanged();
      ItemStack stackSlot = slot.getStack();
      ItemStack stackHeld = playerInv.getItemStack();

      if (stackSlot == null && stackHeld != null && slot.slotNumber != 22) {
        if (isItemValid(stackHeld)) {
          ItemStack copy = stackHeld.copy();
          copy.stackSize = 1;
          slot.putStack(copy);
        }
      }

      if (stackHeld == null) {
        if (tile instanceof TileFishSorter) {
          ((TileFishSorter) tile).swapSide(slot.slotNumber);
        }
      }
    }

    return null;
  }
 public ItemStack slotClick(
     int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
   if (aSlotIndex < 9) {
     return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
   }
   Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex);
   if (tSlot != null) {
     if (this.mTileEntity.getMetaTileEntity() == null) {
       return null;
     }
     if (aSlotIndex == 27) {
       ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput =
           (!((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput);
       if (((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput) {
         GT_Utility.sendChatToPlayer(aPlayer, "Emit Energy to Outputside");
       } else {
         GT_Utility.sendChatToPlayer(aPlayer, "Don't emit Energy");
       }
       return null;
     }
     if ((aSlotIndex >= 9) && (aSlotIndex < 18)) {
       ItemStack tStack = aPlayer.inventory.getItemStack();
       if (tStack != null) {
         tSlot.putStack(GT_Utility.copy(new Object[] {tStack}));
       } else if (tSlot.getStack() != null) {
         if (aMouseclick == 0) {
           tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1);
           if (tSlot.getStack().stackSize <= 0) {
             tSlot.putStack(null);
           }
         } else {
           tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1);
           if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) {
             tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize();
           }
         }
       }
       return null;
     }
     if ((aSlotIndex >= 18) && (aSlotIndex < 27)) {
       ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity())
               .mTargetSlots[(aSlotIndex - 18)] =
           Math.min(
               99,
               Math.max(
                   0,
                   ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity())
                           .mTargetSlots[(aSlotIndex - 18)]
                       + (aMouseclick == 0 ? -1 : 1) * (aShifthold == 0 ? 1 : 16)));
       return null;
     }
   }
   return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
 }
  public void clear() {
    for (final Slot s : this.craftingSlots) {
      s.putStack(null);
    }

    for (final Slot s : this.outputSlots) {
      s.putStack(null);
    }

    this.detectAndSendChanges();
    this.getAndUpdateOutput();
  }
  @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;
  }
Exemplo n.º 8
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;
 }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int id) {
    ItemStack stack = null;
    Slot slot = (Slot) this.inventorySlots.get(id);

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

      ItemMatterUnit unit = ModuleCrafting.matterUnit;

      if (id < 4) { // tileInv->playerInv
        if (!this.mergeItemStack(stack1, 4, this.inventorySlots.size(), true)) return null;
      } else {
        // playerInv->tileInv
        if (unit.getMaterial(stack) == ModuleCrafting.imagPhase.mat) {
          if (!this.mergeItemStack(stack1, 2, 3, false)) return null;
        } else if (IFItemManager.instance.isSupported(stack)) {
          if (!this.mergeItemStack(stack1, 3, 4, false)) return null;
        } else {
          if (!this.mergeItemStack(stack1, 0, 1, false)) return null;
        }
      }

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

    return stack;
  }
Exemplo n.º 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;
  }
Exemplo n.º 11
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;
  }
Exemplo n.º 12
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;
  }
  @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;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
    ItemStack newItemStack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemStack = slot.getStack();
      newItemStack = itemStack.copy();

      if (slotIndex < chestInventoryRows * chestInventoryColumns) {
        if (!this.mergeItemStack(
            itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false)) {
          return null;
        }
      } else if (!this.mergeItemStack(
          itemStack, 0, chestInventoryRows * chestInventoryColumns, false)) {
        return null;
      }

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

    return newItemStack;
  }
Exemplo n.º 15
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;
 }
Exemplo n.º 16
0
  @Override
  public void putStack(ItemStack stack) {
    if (stack == null) {
      return;
    }

    super.putStack(stack);

    if (stack.getItem() == ObjHandler.kleinStars) {
      int remainingEmc =
          EMCHelper.getKleinStarMaxEmc(stack) - (int) Math.ceil(ItemPE.getEmc(stack));

      if (inv.emc >= remainingEmc) {
        ItemPE.addEmc(stack, remainingEmc);
        inv.removeEmc(remainingEmc);
      } else {
        ItemPE.addEmc(stack, inv.emc);
        inv.emc = 0;
      }
    }

    if (stack.getItem() != ObjHandler.tome) {
      inv.handleKnowledge(stack.copy());
    } else {
      inv.updateOutputs();
    }
  }
 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;
 }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot slot = (Slot) inventorySlots.get(slotID);

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

      // merges the item into player inventory since its in the tileEntity
      if (slotID < tileEntity.getSizeInventory()) {
        if (!this.mergeItemStack(
            stackInSlot, tileEntity.getSizeInventory(), this.inventorySlots.size(), true)) {
          return null;
        }
      }
      // merge into tileEntity inventory, since it is in player's inventory
      else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
    }
    return stack;
  }
Exemplo n.º 19
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;
  }
Exemplo n.º 20
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 slot_index) {
    ItemStack stack = null;
    Slot slot_object = (Slot) inventorySlots.get(slot_index);

    if (slot_object != null && slot_object.getHasStack()) {
      ItemStack stack_in_slot = slot_object.getStack();
      stack = stack_in_slot.copy();

      if (slot_index == 0) {
        if (!mergeItemStack(stack_in_slot, 1, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(stack_in_slot, 0, 1, false)) {
        return null;
      }

      if (stack_in_slot.stackSize == 0) {
        slot_object.putStack(null);
      } else {
        slot_object.onSlotChanged();
      }
    }

    return stack;
  }
Exemplo n.º 22
0
  /**
   * 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 < this.numRows * 9) {
        if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) {
        return null;
      }

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

    return itemstack;
  }
 public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
   Slot slot = getSlot(par2);
   if (slot != null && slot.getHasStack()) {
     ItemStack stack = slot.getStack().copy();
     if (par2 == 0) {
       if (!mergeItemStack(slot.getStack(), 9, this.inventorySlots.size(), true)) {
         return null;
       } else {
         if (slot.getStack().stackSize == 0) {
           putStackInSlot(par2, null);
         } else {
           slot.onSlotChanged();
         }
         return stack;
       }
     } else if (par2 >= 9) {
       if (!mergeItemStack(slot.getStack(), 0, 1, true)) {
         return null;
       } else {
         if (slot.getStack().stackSize == 0) {
           slot.putStack(null);
         } else {
           slot.onSlotChanged();
         }
         return stack;
       }
     }
   }
   return null;
 }
Exemplo n.º 24
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;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotNum) {
    ItemStack itemCopy = null;
    Slot slot = (Slot) this.inventorySlots.get(slotNum);

    if (slot != null && slot.getHasStack()) {
      ItemStack item = slot.getStack();
      itemCopy = item.copy();

      if (slotNum < 9) {
        if (!this.mergeItemStack(item, 9, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(item, 0, 9, false)) {
        return null;
      }

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

    return itemCopy;
  }
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotID);

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

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

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

    return stack;
  }
Exemplo n.º 27
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slot) {
    Slot slotObject = (Slot) inventorySlots.get(slot);
    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      ItemStack stack = stackInSlot.copy();
      if (slot >= 0 && slot < kDecomposerInventoryEnd) {
        if (!mergeItemStack(stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true))
          return null;
      } else if (stackInSlot.itemID == MinechemItems.testTube.itemID) {
        if (!mergeItemStack(
            stackInSlot,
            decomposer.kEmptyTestTubeSlotStart,
            decomposer.kEmptyTestTubeSlotEnd + 1,
            false)) return null;
      } else if (slot >= kPlayerInventorySlotStart) {
        if (!mergeItemStack(stackInSlot, decomposer.kInputSlot, decomposer.kInputSlot + 1, false))
          return null;
      } else if (!mergeItemStack(
          stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true)) return null;

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

      return stack;
    }
    return null;
  }
  @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;
  }
Exemplo n.º 29
0
  @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 par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    final Slot var4 = (Slot) this.inventorySlots.get(par2);

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

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

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

    return var3;
  }