Java Code Examples for net.minecraft.entity.player.InventoryPlayer#getItemStack()
The following examples show how to use
net.minecraft.entity.player.InventoryPlayer#getItemStack() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModularUIGui.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private void renderItemStackOnMouse(int mouseX, int mouseY) { InventoryPlayer inventory = this.mc.player.inventory; ItemStack itemStack = this.draggedStack.isEmpty() ? inventory.getItemStack() : this.draggedStack; if (!itemStack.isEmpty()) { int dragOffset = this.draggedStack.isEmpty() ? 8 : 16; if (!this.draggedStack.isEmpty() && this.isRightMouseClick) { itemStack = itemStack.copy(); itemStack.setCount(MathHelper.ceil((float) itemStack.getCount() / 2.0F)); } else if (this.dragSplitting && this.dragSplittingSlots.size() > 1) { itemStack = itemStack.copy(); itemStack.setCount(this.dragSplittingRemnant); } this.drawItemStack(itemStack, mouseX - guiLeft - 8, mouseY - guiTop - dragOffset, null); } }
Example 2
Source File: ItemListSlotWidget.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private boolean insertHeldItemStack(int button, boolean isClient) { InventoryPlayer inventory = gui.entityPlayer.inventory; int amountToInsert = button == 1 ? 1 : Integer.MAX_VALUE; if (!inventory.getItemStack().isEmpty()) { if (!isClient) { //on server, we lookup item list to see how much we can actually insert ItemStack heldItemStack = inventory.getItemStack(); IItemList itemList = gridWidget.getItemList(); int amountInserted = itemList.insertItem(new ItemStackKey(heldItemStack), Math.min(heldItemStack.getCount(), amountToInsert), false, InsertMode.LOWEST_PRIORITY); heldItemStack.shrink(amountInserted); uiAccess.sendHeldItemUpdate(); gui.entityPlayer.openContainer.detectAndSendChanges(); return amountInserted > 0; } else { //on client we assume we can insert full stack into the network inventory.getItemStack().shrink(amountToInsert); return true; } } return false; }
Example 3
Source File: ContainerPneumaticBase.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
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, modifier); } } else if(stackHeld == null) { adjustPhantomSlot(slot, mouseButton, modifier); slot.onPickupFromSlot(player, playerInv.getItemStack()); } else if(slot.isItemValid(stackHeld)) { if(canStacksMerge(stackSlot, stackHeld)) { adjustPhantomSlot(slot, mouseButton, modifier); } else { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } } } return stack; }
Example 4
Source File: ContainerBase.java From Signals with GNU General Public License v3.0 | 4 votes |
/** * Source: Buildcraft */ /* @Override public ItemStack slotClick(int slotNum, int modifier, int mouseButton, EntityPlayer player){ Slot slot = slotNum < 0 ? null : (Slot)inventorySlots.get(slotNum); if(slot instanceof IPhantomSlot) { return slotClickPhantom(slot, modifier, mouseButton, player); } return super.slotClick(slotNum, modifier, mouseButton, player); } */ private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player){ ItemStack stack = ItemStack.EMPTY; if(mouseButton == 2) { if(((IPhantomSlot)slot).canAdjust()) { slot.putStack(ItemStack.EMPTY); } } else if(mouseButton == 0 || mouseButton == 1) { InventoryPlayer playerInv = player.inventory; slot.onSlotChanged(); ItemStack stackSlot = slot.getStack(); ItemStack stackHeld = playerInv.getItemStack(); if(!stackSlot.isEmpty()) { stack = stackSlot.copy(); } if(stackSlot.isEmpty()) { if(!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } } else if(stackHeld.isEmpty()) { adjustPhantomSlot(slot, mouseButton, modifier); slot.onTake(player, playerInv.getItemStack()); } else if(slot.isItemValid(stackHeld)) { if(canStacksMerge(stackSlot, stackHeld)) { adjustPhantomSlot(slot, mouseButton, modifier); } else { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } } } return stack; }
Example 5
Source File: ECContainer.java From ExtraCells1 with MIT License | 4 votes |
private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player) { ItemStack stack = null; if (mouseButton == 2) { if (((SlotFake) 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, modifier); } } else if (stackHeld == null) { adjustPhantomSlot(slot, mouseButton, modifier); slot.onPickupFromSlot(player, playerInv.getItemStack()); } else if (slot.isItemValid(stackHeld)) { if (canStacksMerge(stackSlot, stackHeld)) { adjustPhantomSlot(slot, mouseButton, modifier); } else { fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } } } return stack; }