Package net.minecraftforge.items
Class ItemHandlerHelper
java.lang.Object
net.minecraftforge.items.ItemHandlerHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
calcRedstoneFromInventory
(@Nullable IItemHandler inv) This method uses the standard vanilla algorithm to calculate a comparator output for how "full" the inventory is.static boolean
canItemStacksStack
(@NotNull ItemStack a, @NotNull ItemStack b) static @NotNull ItemStack
copyStackWithSize
(@NotNull ItemStack itemStack, int size) static void
giveItemToPlayer
(Player player, @NotNull ItemStack stack) giveItemToPlayer without preferred slotstatic void
giveItemToPlayer
(Player player, @NotNull ItemStack stack, int preferredSlot) Inserts the given itemstack into the players inventory.static @NotNull ItemStack
insertItem
(IItemHandler dest, @NotNull ItemStack stack, boolean simulate) static @NotNull ItemStack
insertItemStacked
(IItemHandler inventory, @NotNull ItemStack stack, boolean simulate) Inserts the ItemStack into the inventory, filling up already present stacks first.
-
Constructor Details
-
ItemHandlerHelper
public ItemHandlerHelper()
-
-
Method Details
-
insertItem
@NotNull public static @NotNull ItemStack insertItem(IItemHandler dest, @NotNull @NotNull ItemStack stack, boolean simulate) -
canItemStacksStack
-
copyStackWithSize
-
insertItemStacked
@NotNull public static @NotNull ItemStack insertItemStacked(IItemHandler inventory, @NotNull @NotNull 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. -
giveItemToPlayer
giveItemToPlayer without preferred slot -
giveItemToPlayer
public static void giveItemToPlayer(Player player, @NotNull @NotNull ItemStack stack, int preferredSlot) 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
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.
-