Class InventoryUtil

java.lang.Object
me.hackware.api.util.InventoryUtil

public class InventoryUtil extends Object
Inventory search and manipulation utilities.
  • Constructor Details

    • InventoryUtil

      public InventoryUtil()
  • Method Details

    • find

      public static InventoryUtil.FindItemResult find(net.minecraft.world.item.Item item)
      Finds an item anywhere in the player's inventory (hotbar + main).
    • find

      public static InventoryUtil.FindItemResult find(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Finds an item matching a predicate anywhere in the inventory.
    • findInHotbar

      public static InventoryUtil.FindItemResult findInHotbar(net.minecraft.world.item.Item item)
      Finds an item only in the hotbar (slots 0-8).
    • findInHotbar

      public static InventoryUtil.FindItemResult findInHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Finds an item matching a predicate only in the hotbar.
    • findInHotbarWithOffhand

      public static InventoryUtil.FindItemResult findInHotbarWithOffhand(net.minecraft.world.item.Item item)
      Finds an item preferring the offhand, then the hotbar.
    • findInHotbarWithOffhand

      public static InventoryUtil.FindItemResult findInHotbarWithOffhand(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Finds an item matching a predicate, preferring the offhand, then the hotbar.
    • findWithOffhand

      public static InventoryUtil.FindItemResult findWithOffhand(net.minecraft.world.item.Item item)
      Finds an item preferring the offhand, then the hotbar, then the main inventory.
    • findWithOffhand

      public static InventoryUtil.FindItemResult findWithOffhand(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Finds an item matching a predicate, preferring the offhand, then the hotbar, then the main inventory.
    • fireworkRefireTicks

      public static int fireworkRefireTicks(net.minecraft.world.item.ItemStack stack)
      Ticks until another firework rocket of this flight duration can meaningfully re-fire.
    • swap

      public static boolean swap(int slot)
      Swaps the given hotbar slot to the player's selected slot. Returns true if the swap was performed.
    • moveToHotbar

      public static int moveToHotbar(int invSlot, int hotbarSlot)
      Silently moves an item from the main inventory (slot 9-35) into a hotbar slot using inventory container clicks. Returns the hotbar slot it was moved to, or -1 on failure. The item at the target hotbar slot is swapped into the original inventory slot.
    • moveBackFromHotbar

      public static void moveBackFromHotbar(int invSlot, int hotbarSlot)
      Reverses a previous moveToHotbar by swapping the hotbar slot back with the original inventory slot.
    • silentSwapEquipChestplate

      public static boolean silentSwapEquipChestplate()
      Silently equips a chestplate from the inventory using slot clicks. Returns false if already wearing a chestplate or none found.
    • silentSwapEquipElytra

      public static boolean silentSwapEquipElytra()
      Silently equips an elytra from the inventory using slot clicks. Returns false if already wearing an elytra or none found.
    • findUsableElytra

      public static InventoryUtil.FindItemResult findUsableElytra()
      The most durable elytra anywhere in the inventory that can still deploy (durability > 1).
    • toContainerSlot

      public static int toContainerSlot(int invSlot)
      Converts a player inventory slot index (0-35) to the corresponding container slot index in the player's inventory menu. Hotbar slots 0-8 → container slots 36-44 Main slots 9-35 → container slots 9-35