/** * 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; }
@Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { // we always want to shiftclick the output into a pattern chest if present // note that we leave out a few checks/callbacks because we rely on how the stenciltable works if (index != 1) { return super.transferStackInSlot(playerIn, index); } Slot slot = (Slot) this.inventorySlots.get(index); if (slot == null || !slot.getHasStack()) { return null; } ItemStack itemstack = slot.getStack().copy(); ItemStack ret = slot.getStack().copy(); if (patternChestSideInventory != null) { if (moveToContainer(itemstack, patternChestSideInventory)) { return null; } return notifySlotAfterTransfer(playerIn, itemstack, ret, slot); } return super.transferStackInSlot(playerIn, index); }
@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; }
@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; }
@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; }
@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; }
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */ @Override public ItemStack transferStackInSlot(EntityPlayer player, 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 < 3 * 5) { if (!mergeItemStack(itemstack1, 3 * 5, inventorySlots.size(), true)) { return null; } } else if (!mergeItemStack(itemstack1, 0, 3 * 5, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } } return itemstack; }
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; }
@Override public ItemStack transferStackInSlot(EntityPlayer entityplayer, int slotID) { Slot slot = (Slot) this.inventorySlots.get(slotID); ItemStack itemstack = slot.getStack(); return itemstack; }
private boolean shouldDrawLid(Slot slot) { InventoryCamera inv = container.inventory(); return (inv.isLidClosed() || lidXSize != 0) && slot.inventory == inv && slot.getHasStack() && inv.storageSlot() == slot.getSlotIndex(); }
@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 < BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS) { if (!this.mergeItemStack( itemStack, BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS, inventorySlots.size(), false)) return null; } else if (!this.mergeItemStack( itemStack, 0, BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS, false)) return null; if (itemStack.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } } return newItemStack; }
@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; }
@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; }
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; }
@Override public List<String> getTooltip(PC_Vec2I position) { Slot slot = getSlotAtPosition(position); if (slot != null) { ItemStack itemstack = null; if (slot.getHasStack()) itemstack = slot.getStack(); // if (slot instanceof PC_Slot && ((PC_Slot) slot).getBackgroundStack() != null && ((PC_Slot) // slot).renderTooltipWhenEmpty()) // itemstack = ((PC_Slot) slot).getBackgroundStack(); if (itemstack != null) { @SuppressWarnings("unchecked") List<String> l = itemstack.getTooltip( PC_ClientUtils.mc().thePlayer, PC_ClientUtils.mc().gameSettings.advancedItemTooltips); for (int k = 0; k < l.size(); ++k) { if (k == 0) { l.set(k, itemstack.getRarity().rarityColor + l.get(k)); } else { l.set(k, EnumChatFormatting.GRAY + l.get(k)); } } return l; } } return super.getTooltip(position); }
@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; }
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; }
/** 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()); } } }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) { ItemStack stack = null; Slot slot = (Slot) inventorySlots.get(slotNumber); if (slot != null && slot.getHasStack()) { ItemStack slotClicked = slot.getStack(); stack = slotClicked.copy(); if (slotNumber <= 36) { if (slotNumber == 0 && stack != null && stack.stackSize > 0) { tile.decrementCraftingField(); } if (!mergeItemStack(slotClicked, 37, inventorySlots.size(), true)) { return null; } } else { stack = null; } if (slotClicked.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } } return stack; }
@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; }
protected void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton) { if (!((IPhantomSlot) slot).canAdjust()) return; int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1; if (stackSize > slot.getSlotStackLimit()) stackSize = slot.getSlotStackLimit(); ItemStack phantomStack = stackHeld.copy(); phantomStack.stackSize = stackSize; slot.putStack(phantomStack); }
/** * @param itemStack ItemStack to merge into inventory * @param start minimum slot to attempt fill * @param end maximum slot to attempt fill * @param backwards go backwards * @return true if stacks merged successfully */ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); stack = slotObject.getStack(); return stack; }
@SuppressWarnings("unchecked") public static void deleteAllItems(EntityPlayerMP player) { for (Slot slot : (List<Slot>) player.openContainer.inventorySlots) { slot.putStack(null); } player.updateCraftingInventory(player.openContainer, player.openContainer.getInventory()); }
protected void handleMouseClick( Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) { if (p_146984_1_ != null && p_146984_2_ != -999) { Debug.println("p_146984_1_", p_146984_1_.slotNumber + ""); Debug.println("p_146984_2_", p_146984_2_ + ""); Debug.println("p_146984_3_", p_146984_3_ + ""); Debug.println("p_146984_4_", p_146984_4_ + ""); if (p_146984_1_ != null && p_146984_1_.getHasStack()) { ItemStack itemstack = p_146984_1_.getStack(); ItemStack itemstack2; List recipes = CustomCraftingManager.getInstance().getRecipeList(); for (int j = 0; j < recipes.size(); ++j) { IRecipe irecipe = (IRecipe) recipes.get(j); itemstack2 = irecipe.getRecipeOutput(); if (itemstack2 != null) { if (itemstack2.getItem() == itemstack.getItem() && itemstack.getItemDamage() == itemstack2.getItemDamage()) { ItemStack[][] RezeptAr = irecipe.getRecipe(itemstack2); Debug.println( irecipe.getClass().getName(), irecipe.getClass().getName() + " " + itemstack2.getItemDamage()); if (irecipe.getRecipe(itemstack2) != null) { craftResult.setInventorySlotContents(0, itemstack2); // irecipe. for (int i = 0; i < RezeptAr.length; i++) { for (int ii = 0; ii < RezeptAr[i].length; ii++) { recipefield.setInventorySlotContents((i * 3) + ii, null); ItemStack Rezeptitem = RezeptAr[i][ii]; if (Rezeptitem != null) { Debug.println( i + "/" + ii, Rezeptitem.getDisplayName() + " " + Rezeptitem.getItemDamage()); Rezeptitem.stackSize = 1; recipefield.setInventorySlotContents((i * 3) + ii, Rezeptitem); } } } Debug.println("itemstack", itemstack.getDisplayName() + ""); break; } } } } } ((CreativeInv.ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll); // this.scrollTo(0.0F); } }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotId) { Slot slotToTransfer = getSlot(slotId); if (slotToTransfer == null || !slotToTransfer.getHasStack()) { return null; } ItemStack stackToTransfer = slotToTransfer.getStack(); ItemStack oldStack = stackToTransfer.copy(); if (slotId < inventory.getSizeInventory()) { // transfer from crystal bag to inventory if (!mergeItemStack( stackToTransfer, inventory.getSizeInventory(), inventory.getSizeInventory() + 36, true)) { return null; } } else { // transfer from inventory if (stackToTransfer.itemID == QuestologyItem.crystal.itemID) { // its a crystal if (!mergeItemStack( stackToTransfer, 0, inventory.getSizeInventory(), false)) { // merge into the crystal bag return null; } } else { // its some other item if (slotId >= inventory.getSizeInventory() + 27) { // its in the hotbar if (!mergeItemStack( stackToTransfer, inventory.getSizeInventory(), inventory.getSizeInventory() + 27, false)) { // merge it with the upper 3 rows return null; } } else { // its in the upper 3 rows of the player inventory if (!mergeItemStack( stackToTransfer, inventory.getSizeInventory() + 27, inventory.getSizeInventory() + 36, false)) { // merge it with the hotbar return null; } } } } if (stackToTransfer.stackSize == 0) { slotToTransfer.putStack(null); // completely transferred } else { slotToTransfer.onSlotChanged(); // only partially transferred } if (stackToTransfer.stackSize == oldStack.stackSize) { return null; // we cannot transfer this stack } return oldStack; }
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); /** * If we are shift-clicking an item out of the Research Table's container, attempt to put it * in the first available slot in the entityPlayer's inventory */ if (slotIndex < TileEntityResearchStation.INVENTORY_SIZE) { if (!this.mergeItemStack( slotItemStack, TileEntityResearchStation.INVENTORY_SIZE, inventorySlots.size(), false)) { return null; } } else { /** * If the stack being shift-clicked into the Research Table's container is a fuel, first try * to put it in the fuel slot. If it cannot be merged into the fuel slot, try to put it in * the input slot. */ if (slotItemStack.getItem() instanceof ItemAlchemicalTome) { if (!this.mergeItemStack( slotItemStack, TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX, TileEntityResearchStation.INVENTORY_SIZE, false)) { return null; } } else { if (!this.mergeItemStack( slotItemStack, TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX, false)) { return null; } } } if (slotItemStack.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } } 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; }
protected void adjustPhantomSlot(Slot slot, int mouseButton, int modifier) { if (!((IPhantomSlot) slot).canAdjust()) return; ItemStack stackSlot = slot.getStack(); int stackSize; if (modifier == 1) stackSize = mouseButton == 0 ? (stackSlot.stackSize + 1) / 2 : stackSlot.stackSize * 2; else stackSize = mouseButton == 0 ? stackSlot.stackSize - 1 : stackSlot.stackSize + 1; if (stackSize > slot.getSlotStackLimit()) stackSize = slot.getSlotStackLimit(); stackSlot.stackSize = stackSize; if (stackSlot.stackSize <= 0) slot.putStack(null); }
/** * 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 p_82846_1_, int p_82846_2_) { if (p_82846_2_ >= this.inventorySlots.size() - 9 && p_82846_2_ < this.inventorySlots.size()) { Slot slot = (Slot) this.inventorySlots.get(p_82846_2_); if (slot != null && slot.getHasStack()) { slot.putStack((ItemStack) null); } } return null; }
public Slot getSlotFromInventory(IInventory par1IInventory, int par2) { for (int var3 = 0; var3 < this.inventorySlots.size(); ++var3) { Slot var4 = (Slot) this.inventorySlots.get(var3); if (var4.isSlotInInventory(par1IInventory, par2)) { return var4; } } return null; }