Package me.hackware.api.util
Class InventoryUtil
java.lang.Object
me.hackware.api.util.InventoryUtil
Inventory search and manipulation utilities.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InventoryUtil.FindItemResultFinds an item matching a predicate anywhere in the inventory.static InventoryUtil.FindItemResultfind(net.minecraft.world.item.Item item) Finds an item anywhere in the player's inventory (hotbar + main).static InventoryUtil.FindItemResultfindInHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate) Finds an item matching a predicate only in the hotbar.static InventoryUtil.FindItemResultfindInHotbar(net.minecraft.world.item.Item item) Finds an item only in the hotbar (slots 0-8).static InventoryUtil.FindItemResultfindInHotbarWithOffhand(Predicate<net.minecraft.world.item.ItemStack> predicate) Finds an item matching a predicate, preferring the offhand, then the hotbar.static InventoryUtil.FindItemResultfindInHotbarWithOffhand(net.minecraft.world.item.Item item) Finds an item preferring the offhand, then the hotbar.static InventoryUtil.FindItemResultThe most durable elytra anywhere in the inventory that can still deploy (durability > 1).static InventoryUtil.FindItemResultfindWithOffhand(Predicate<net.minecraft.world.item.ItemStack> predicate) Finds an item matching a predicate, preferring the offhand, then the hotbar, then the main inventory.static InventoryUtil.FindItemResultfindWithOffhand(net.minecraft.world.item.Item item) Finds an item preferring the offhand, then the hotbar, then the main inventory.static intfireworkRefireTicks(net.minecraft.world.item.ItemStack stack) Ticks until another firework rocket of this flight duration can meaningfully re-fire.static voidmoveBackFromHotbar(int invSlot, int hotbarSlot) Reverses a previous moveToHotbar by swapping the hotbar slot back with the original inventory slot.static intmoveToHotbar(int invSlot, int hotbarSlot) Silently moves an item from the main inventory (slot 9-35) into a hotbar slot using inventory container clicks.static booleanSilently equips a chestplate from the inventory using slot clicks.static booleanSilently equips an elytra from the inventory using slot clicks.static booleanswap(int slot) Swaps the given hotbar slot to the player's selected slot.static inttoContainerSlot(int invSlot) Converts a player inventory slot index (0-35) to the corresponding container slot index in the player's inventory menu.
-
Constructor Details
-
InventoryUtil
public InventoryUtil()
-
-
Method Details
-
find
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
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
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
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
-