Class InventoryUtils

java.lang.Object
org.rusherhack.client.api.utils.InventoryUtils
All Implemented Interfaces:
Globals

public class InventoryUtils extends Object implements Globals
Helper class containing inventory related functions
  • Field Summary

    Fields inherited from interface org.rusherhack.client.api.Globals

    mc
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    clickSlot(int slotId, boolean shiftClick)
    Clicks a slot in the player's inventory
    static int
    findItem(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarPriority, boolean includeOffhand)
    Finds an item in the player's inventory
    static int
    findItem(Predicate<net.minecraft.world.item.ItemStack> predicate, Comparator<net.minecraft.world.item.ItemStack> comparator, boolean hotbarPriority, boolean includeOffhand)
    Finds an item in the player's inventory
    static int
    findItem(net.minecraft.world.item.Item item, boolean hotbarPriority, boolean includeOffhand)
    Finds an item in the player's inventory
    static int
    findItemHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate)
    Finds an item in the player's hotbar
    static int
    findItemHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate, Comparator<net.minecraft.world.item.ItemStack> comparator)
    Finds an item in the player's hotbar
    static int
    findItemHotbar(net.minecraft.world.item.Item item)
    Finds an item in the player's hotbar
    static int
    getInventorySlot(net.minecraft.world.entity.EquipmentSlot equipmentSlot)
     
    static int
    getItemCount(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarOnly, boolean includeOffhand)
    Gets the count of an item in the player's inventory
    static int
    getItemCount(net.minecraft.world.item.Item item, boolean hotbarOnly, boolean includeOffhand)
    Gets the count of an item in the player's inventory
    static int
    getStackCount(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarOnly, boolean includeOffhand)
    Gets the count of item stacks matching the specified predicate
    static boolean
     
    static void
    loopInventory(BiFunction<Integer,net.minecraft.world.item.ItemStack,Boolean> consumer, boolean includeInventory, boolean includeOffhand, boolean includeHotbar, boolean hotbarPriority)
     
    static void
    swapSlots(int fromSlot, int toSlot)
    Swaps 2 item slots in the player's inventory

    Methods inherited from class java.lang.Object

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

    • InventoryUtils

      public InventoryUtils()
  • Method Details

    • clickSlot

      public static void clickSlot(int slotId, boolean shiftClick)
      Clicks a slot in the player's inventory
      Parameters:
      slotId - the slot id in standard inventory slot numbers
      See Also:
    • swapSlots

      public static void swapSlots(int fromSlot, int toSlot)
      Swaps 2 item slots in the player's inventory
      Parameters:
      fromSlot - the slot id in standard inventory slot numbers
      toSlot - the slot id in hotbar slot numbers (hotbar: 0 - 8, offhand: 40)
      See Also:
    • findItem

      public static int findItem(net.minecraft.world.item.Item item, boolean hotbarPriority, boolean includeOffhand)
      Finds an item in the player's inventory
      Parameters:
      item - the item to find
      hotbarPriority -
      includeOffhand - whether to include the offhand slot
      Returns:
      the inventory slot id of the item, or -1 if not found.
      See Also:
    • findItem

      public static int findItem(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarPriority, boolean includeOffhand)
      Finds an item in the player's inventory
      Parameters:
      predicate -
      hotbarPriority -
      includeOffhand - whether to include the offhand slot
      Returns:
      the inventory slot id of the item, or -1 if not found.
      See Also:
    • findItem

      public static int findItem(Predicate<net.minecraft.world.item.ItemStack> predicate, Comparator<net.minecraft.world.item.ItemStack> comparator, boolean hotbarPriority, boolean includeOffhand)
      Finds an item in the player's inventory
      Parameters:
      predicate -
      comparator - a comparator for which each valid stack will be compared against the previous valid stack
      hotbarPriority -
      includeOffhand - whether to include the offhand slot
      Returns:
      the inventory slot id of the item, or -1 if not found.
      See Also:
    • findItemHotbar

      public static int findItemHotbar(net.minecraft.world.item.Item item)
      Finds an item in the player's hotbar
      Parameters:
      item - the item to find
      Returns:
      the hotbar slot id of the item, or -1 if not found.
    • findItemHotbar

      public static int findItemHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Finds an item in the player's hotbar
      Parameters:
      predicate -
      Returns:
      the hotbar slot id of the item, or -1 if not found.
    • findItemHotbar

      public static int findItemHotbar(Predicate<net.minecraft.world.item.ItemStack> predicate, Comparator<net.minecraft.world.item.ItemStack> comparator)
      Finds an item in the player's hotbar
      Parameters:
      predicate -
      comparator - a comparator for which each valid stack will be compared against the previous valid stack
      Returns:
      the hotbar slot id of the item, or -1 if not found.
    • getItemCount

      public static int getItemCount(net.minecraft.world.item.Item item, boolean hotbarOnly, boolean includeOffhand)
      Gets the count of an item in the player's inventory
      Parameters:
      item - the item to count
      hotbarOnly - whether to only search the hotbar
      includeOffhand - whether to include the offhand slot
      Returns:
      the number of the item that the player has
    • getItemCount

      public static int getItemCount(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarOnly, boolean includeOffhand)
      Gets the count of an item in the player's inventory
      Parameters:
      predicate -
      hotbarOnly - whether to only search the hotbar
      includeOffhand - whether to include the offhand slot
      Returns:
      the number of the item that the player has
    • getStackCount

      public static int getStackCount(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarOnly, boolean includeOffhand)
      Gets the count of item stacks matching the specified predicate
      Parameters:
      predicate -
      hotbarOnly - whether to only search the hotbar
      includeOffhand - whether to include the offhand slot
      Returns:
      the number of stacks of the item that the player has
    • loopInventory

      public static void loopInventory(BiFunction<Integer,net.minecraft.world.item.ItemStack,Boolean> consumer, boolean includeInventory, boolean includeOffhand, boolean includeHotbar, boolean hotbarPriority)
      Parameters:
      consumer - the consumer to apply to each slot
      includeInventory - whether to include the player's inventory
      includeOffhand - whether to include the offhand slot
      includeHotbar - whether to include the player's hotbar
      hotbarPriority - whether to loop the hotbar first
    • isInventoryFull

      public static boolean isInventoryFull()
    • getInventorySlot

      public static int getInventorySlot(net.minecraft.world.entity.EquipmentSlot equipmentSlot)