Class InventoryHelper

java.lang.Object
com.gtnewhorizons.horizonqa.api.InventoryHelper

public final class InventoryHelper extends Object
Utility for inserting into / querying IInventory and ISidedInventory tile entities without knowing which interface the block implements.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    clearSlot(net.minecraft.inventory.IInventory inventory, int slot)
    Directly clear a slot, bypassing normal extraction rules, then mark the inventory dirty.
    static boolean
    contains(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack)
    Check if the inventory contains at least stack.stackSize items matching stack.
    static long
    count(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template)
    Count all items matching template by item, damage, and NBT across the inventory.
    static int
    extract(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template, int maxAmount)
    Extract up to maxAmount items matching template (item + meta + NBT) from the inventory.
    static net.minecraft.item.ItemStack
    getSlot(net.minecraft.inventory.IInventory inventory, int slot)
    Get the ItemStack at a specific slot, or null.
    static int
    insert(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack)
    Insert stack into the inventory at the given tile.
    static boolean
    isEmpty(net.minecraft.inventory.IInventory inventory)
    Check if every slot in the inventory is null or has stackSize 0.
    static void
    setSlot(net.minecraft.inventory.IInventory inventory, int slot, net.minecraft.item.ItemStack stack)
    Directly set a slot to a copy of stack, bypassing normal insertion rules, then mark the inventory dirty.
    static boolean
    stacksMatch(net.minecraft.item.ItemStack a, net.minecraft.item.ItemStack b)
    Match two stacks by item, damage, and NBT (ignoring stack size).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • insert

      public static int insert(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack stack)
      Insert stack into the inventory at the given tile. Tries ISidedInventory first (testing all sides), then falls back to plain IInventory scanning. 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 to maxAmount items matching template (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 least stack.stackSize items matching stack.
    • count

      public static long count(net.minecraft.inventory.IInventory inventory, net.minecraft.item.ItemStack template)
      Count all items matching template by 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 the ItemStack at 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 of stack, 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).