Package com.gtnewhorizons.horizonqa.api
Class InventoryHelper
java.lang.Object
com.gtnewhorizons.horizonqa.api.InventoryHelper
Utility for inserting into / querying
IInventory and ISidedInventory tile entities
without knowing which interface the block implements.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearSlot(net.minecraft.inventory.IInventory inventory, int slot) Directly clear a slot, bypassing normal extraction rules, then mark the inventory dirty.static booleancontains(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack) Check if the inventory contains at leaststack.stackSizeitems matchingstack.static longcount(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template) Count all items matchingtemplateby item, damage, and NBT across the inventory.static intextract(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template, int maxAmount) Extract up tomaxAmountitems matchingtemplate(item + meta + NBT) from the inventory.static net.minecraft.item.ItemStackgetSlot(net.minecraft.inventory.IInventory inventory, int slot) Get theItemStackat a specific slot, or null.static intinsert(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack) Insertstackinto the inventory at the given tile.static booleanisEmpty(net.minecraft.inventory.IInventory inventory) Check if every slot in the inventory is null or has stackSize 0.static voidsetSlot(net.minecraft.inventory.IInventory inventory, int slot, net.minecraft.item.ItemStack stack) Directly set a slot to a copy ofstack, bypassing normal insertion rules, then mark the inventory dirty.static booleanstacksMatch(net.minecraft.item.ItemStack a, net.minecraft.item.ItemStack b) Match two stacks by item, damage, and NBT (ignoring stack size).
-
Method Details
-
insert
public static int insert(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack) Insertstackinto the inventory at the given tile. TriesISidedInventoryfirst (testing all sides), then falls back to plainIInventoryscanning. Returns the leftover amount that could not be inserted (0 = fully inserted). -
extract
public static int extract(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template, int maxAmount) Extract up tomaxAmountitems matchingtemplate(item + meta + NBT) from the inventory. Returns the actual amount extracted. -
contains
public static boolean contains(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack) Check if the inventory contains at leaststack.stackSizeitems matchingstack. -
count
public static long count(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template) Count all items matchingtemplateby item, damage, and NBT across the inventory. -
isEmpty
public static boolean isEmpty(net.minecraft.inventory.IInventory inventory) Check if every slot in the inventory is null or has stackSize 0. -
getSlot
public static net.minecraft.item.ItemStack getSlot(net.minecraft.inventory.IInventory inventory, int slot) Get theItemStackat a specific slot, or null. -
setSlot
public static void setSlot(net.minecraft.inventory.IInventory inventory, int slot, net.minecraft.item.ItemStack stack) Directly set a slot to a copy ofstack, bypassing normal insertion rules, then mark the inventory dirty. -
clearSlot
public static void clearSlot(net.minecraft.inventory.IInventory inventory, int slot) Directly clear a slot, bypassing normal extraction rules, then mark the inventory dirty. -
stacksMatch
public static boolean stacksMatch(net.minecraft.item.ItemStack a, net.minecraft.item.ItemStack b) Match two stacks by item, damage, and NBT (ignoring stack size).
-