Package net.neoforged.neoforge.items
Class ItemHandlerHelper
java.lang.Object
net.neoforged.neoforge.items.ItemHandlerHelper
Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcRedstoneFromInventory(@Nullable IItemHandler inv) Deprecated, for removal: This API element is subject to removal in a future version.static voidgiveItemToPlayer(Player player, ItemStack stack) Deprecated, for removal: This API element is subject to removal in a future version.static voidgiveItemToPlayer(Player player, ItemStack stack, int preferredSlot) Deprecated, for removal: This API element is subject to removal in a future version.static ItemStackinsertItem(IItemHandler dest, ItemStack stack, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.static ItemStackinsertItemStacked(IItemHandler inventory, ItemStack stack, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
ItemHandlerHelper
public ItemHandlerHelper()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
insertItem
@Deprecated(since="1.21.9", forRemoval=true) public static ItemStack insertItem(IItemHandler dest, ItemStack stack, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandler.insert(Resource, int, TransactionContext)instead. Note thatResourceHandler.insertreturns how much was inserted, unlike this method which returns the leftover (i.e. how much was not inserted). Alternatively use theItemUtil.insertItemReturnRemaining(net.neoforged.neoforge.transfer.ResourceHandler<net.neoforged.neoforge.transfer.item.ItemResource>, net.minecraft.world.item.ItemStack, boolean, net.neoforged.neoforge.transfer.transaction.TransactionContext)helper. -
insertItemStacked
@Deprecated(since="1.21.9", forRemoval=true) public static ItemStack insertItemStacked(IItemHandler inventory, ItemStack stack, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.UseResourceHandlerUtil.insertStacking(ResourceHandler, Resource, int, TransactionContext)instead. Note thatResourceHandlerUtil.insertStackingreturns how much was inserted, unlike this method which returns the leftover (i.e. how much was not inserted).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. -
giveItemToPlayer
@Deprecated(since="1.21.9", forRemoval=true) public static void giveItemToPlayer(Player player, ItemStack stack) Deprecated, for removal: This API element is subject to removal in a future version.giveItemToPlayer without preferred slot -
giveItemToPlayer
@Deprecated(since="1.21.9", forRemoval=true) public static void giveItemToPlayer(Player player, ItemStack stack, int preferredSlot) Deprecated, for removal: This API element is subject to removal in a future version.Inserts 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 tostack- The itemstack to insert
-
calcRedstoneFromInventory
@Deprecated(since="1.21.9", forRemoval=true) public static int calcRedstoneFromInventory(@Nullable @Nullable IItemHandler inv) Deprecated, for removal: This API element is subject to removal in a future version.This 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.
-
ResourceHandlerwith anItemResourceinstead ofIItemHandler. For available utils, seeResourceHandlerUtilas well asItemUtil.