Java Code Examples for net.minecraft.item.Item#getContainerItem()
The following examples show how to use
net.minecraft.item.Item#getContainerItem() .
These examples are extracted from open source projects.
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 Project: CodeChickenLib File: InventoryUtils.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Consumes one item from slot in inv with support for containers. */ public static void consumeItem(IInventory inv, int slot) { ItemStack stack = inv.getStackInSlot(slot); Item item = stack.getItem(); if (item.hasContainerItem(stack)) { ItemStack container = item.getContainerItem(stack); inv.setInventorySlotContents(slot, container); } else { inv.decrStackSize(slot, 1); } }
Example 2
Source Project: CodeChickenLib File: InventoryUtils.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Consumes one item from slot in inv with support for containers. */ public static void consumeItem(IInventory inv, int slot) { ItemStack stack = inv.getStackInSlot(slot); Item item = stack.getItem(); if (item.hasContainerItem(stack)) { ItemStack container = item.getContainerItem(stack); inv.setInventorySlotContents(slot, container); } else { inv.decrStackSize(slot, 1); } }
Example 3
Source Project: OpenModsLib File: ItemUtils.java License: MIT License | 5 votes |
@Nonnull public static ItemStack consumeItem(@Nonnull ItemStack stack) { if (stack.getCount() == 1) { final Item item = stack.getItem(); if (item.hasContainerItem(stack)) return item.getContainerItem(stack); return ItemStack.EMPTY; } stack.splitStack(1); return stack; }