Package org.rusherhack.client.api.utils
Class InventoryUtils
java.lang.Object
org.rusherhack.client.api.utils.InventoryUtils
- All Implemented Interfaces:
Globals
Helper class containing inventory related functions
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clickSlot
(int slotId, boolean shiftClick) Clicks a slot in the player's inventorystatic int
findItem
(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarPriority, boolean includeOffhand) Finds an item in the player's inventorystatic 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 inventorystatic int
findItem
(net.minecraft.world.item.Item item, boolean hotbarPriority, boolean includeOffhand) Finds an item in the player's inventorystatic int
findItemHotbar
(Predicate<net.minecraft.world.item.ItemStack> predicate) Finds an item in the player's hotbarstatic int
findItemHotbar
(Predicate<net.minecraft.world.item.ItemStack> predicate, Comparator<net.minecraft.world.item.ItemStack> comparator) Finds an item in the player's hotbarstatic int
findItemHotbar
(net.minecraft.world.item.Item item) Finds an item in the player's hotbarstatic 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 inventorystatic int
getItemCount
(net.minecraft.world.item.Item item, boolean hotbarOnly, boolean includeOffhand) Gets the count of an item in the player's inventorystatic int
getStackCount
(Predicate<net.minecraft.world.item.ItemStack> predicate, boolean hotbarOnly, boolean includeOffhand) Gets the count of item stacks matching the specified predicatestatic 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
-
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 numberstoSlot
- 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 findhotbarPriority
-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 stackhotbarPriority
-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
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 counthotbarOnly
- whether to only search the hotbarincludeOffhand
- 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 hotbarincludeOffhand
- 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 hotbarincludeOffhand
- 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 slotincludeInventory
- whether to include the player's inventoryincludeOffhand
- whether to include the offhand slotincludeHotbar
- whether to include the player's hotbarhotbarPriority
- whether to loop the hotbar first
-
isInventoryFull
public static boolean isInventoryFull() -
getInventorySlot
public static int getInventorySlot(net.minecraft.world.entity.EquipmentSlot equipmentSlot)
-