Package net.minecraftforge.items
Class ItemHandlerHelper
- java.lang.Object
-
- net.minecraftforge.items.ItemHandlerHelper
-
public class ItemHandlerHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ItemHandlerHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcalcRedstoneFromInventory(IItemHandler inv)This method uses the standard vanilla algorithm to calculate a comparator output for how "full" the inventory is.static booleancanItemStacksStack(ItemStack a, ItemStack b)static booleancanItemStacksStackRelaxed(ItemStack a, ItemStack b)A relaxed version of canItemStacksStack that stacks itemstacks with different metadata if they don't have subtypes.static ItemStackcopyStackWithSize(ItemStack itemStack, int size)static voidgiveItemToPlayer(PlayerEntity player, ItemStack stack)giveItemToPlayer without preferred slotstatic voidgiveItemToPlayer(PlayerEntity 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.
-
-
-
Method Detail
-
insertItem
@Nonnull public static ItemStack insertItem(IItemHandler dest, @Nonnull ItemStack stack, boolean simulate)
-
canItemStacksStack
public static boolean canItemStacksStack(@Nonnull ItemStack a, @Nonnull ItemStack b)
-
canItemStacksStackRelaxed
public static boolean canItemStacksStackRelaxed(@Nonnull ItemStack a, @Nonnull ItemStack b)A relaxed version of canItemStacksStack that stacks itemstacks with different metadata if they don't have subtypes. This usually only applies when players pick up items.
-
copyStackWithSize
@Nonnull public static ItemStack copyStackWithSize(@Nonnull ItemStack itemStack, int size)
-
insertItemStacked
@Nonnull public static ItemStack insertItemStacked(IItemHandler inventory, @Nonnull 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
public static void giveItemToPlayer(PlayerEntity player, @Nonnull ItemStack stack)
giveItemToPlayer without preferred slot
-
giveItemToPlayer
public static void giveItemToPlayer(PlayerEntity player, @Nonnull 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
public static int calcRedstoneFromInventory(@Nullable IItemHandler inv)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.
-
-