Package net.neoforged.neoforge.items
Class ItemHandlerHelper
java.lang.Object
net.neoforged.neoforge.items.ItemHandlerHelper
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic intcalcRedstoneFromInventory(@Nullable IItemHandler inv) This method uses the standard vanilla algorithm to calculate a comparator output for how "full" the inventory is.static booleanDeprecated, for removal: This API element is subject to removal in a future version.static ItemStackcopyStackWithSize(ItemStack stack, int count) Deprecated, for removal: This API element is subject to removal in a future version.static voidgiveItemToPlayer(Player player, ItemStack stack) giveItemToPlayer without preferred slotstatic voidgiveItemToPlayer(Player player, ItemStack stack, int preferredSlot) Inserts the given itemstack into the players inventory.static ItemStackinsertItem(IItemHandler dest, ItemStack stack, boolean simulate) static ItemStackinsertItemStacked(IItemHandler inventory, ItemStack stack, boolean simulate) Inserts the ItemStack into the inventory, filling up already present stacks first.
- 
Constructor Details- 
ItemHandlerHelperpublic ItemHandlerHelper()
 
- 
- 
Method Details- 
insertItem
- 
canItemStacksStack@Deprecated(forRemoval=true, since="1.20.5") public static boolean canItemStacksStack(ItemStack a, ItemStack b) Deprecated, for removal: This API element is subject to removal in a future version.
- 
copyStackWithSize@Deprecated(forRemoval=true, since="1.20.5") public static ItemStack copyStackWithSize(ItemStack stack, int count) Deprecated, for removal: This API element is subject to removal in a future version.
- 
insertItemStackedpublic static ItemStack insertItemStacked(IItemHandler inventory, ItemStack stack, boolean simulate) Inserts the ItemStack into the inventory, filling up already present stacks first. This is equivalent to the behaviour of a player picking up an item. Note: This function stacks items without subtypes with different metadata together.
- 
giveItemToPlayergiveItemToPlayer without preferred slot
- 
giveItemToPlayerInserts the given itemstack into the players inventory. If the inventory can't hold it, the item will be dropped in the world at the players position.- Parameters:
- player- The player to give the item to
- stack- The itemstack to insert
 
- 
calcRedstoneFromInventoryThis method uses the standard vanilla algorithm to calculate a comparator output for how "full" the inventory is. This method is an adaptation of Container#calcRedstoneFromInventory(IInventory).- Parameters:
- inv- The inventory handler to test.
- Returns:
- A redstone value in the range [0,15] representing how "full" this inventory is.
 
 
- 
ItemStack.isSameItemSameComponents(ItemStack, ItemStack)