Package dev.boze.api.utility.interaction
Class InvHelper
java.lang.Object
dev.boze.api.utility.interaction.InvHelper
InvHelper provides utilities for finding items in the player's inventory
WARNING: Always swap back after swapping with silent/alt mode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intFind the first slot matching the predicate in the entire inventorystatic intfind(net.minecraft.block.Block block) Find the first slot containing a block in the entire inventorystatic intfind(net.minecraft.block.Block... blocks) Find the first slot containing any of the specified blocks in the entire inventorystatic intfind(net.minecraft.item.Item item) Find the first slot containing an item in the entire inventorystatic intfind(net.minecraft.item.Item... items) Find the first slot containing any of the specified items in the entire inventorystatic intfindInHotbar(Predicate<net.minecraft.item.ItemStack> test) Find the first slot matching the predicate in the hotbarstatic intfindInHotbar(net.minecraft.block.Block block) Find the first slot containing a block in the hotbarstatic intfindInHotbar(net.minecraft.block.Block... blocks) Find the first slot containing any of the specified blocks in the hotbarstatic intfindInHotbar(net.minecraft.item.Item item) Find the first slot containing an item in the hotbarstatic intfindInHotbar(net.minecraft.item.Item... items) Find the first slot containing any of the specified items in the hotbarstatic voidswapBack()Swap back to the original slotstatic booleanswapToSlot(int slot, SwapType swapType) Swap to the specified slot using the given swap typestatic booleanswapToSlot(int slot, ToggleableSwapType swapType) Swap to the specified slot using the given toggleable swap type
-
Constructor Details
-
InvHelper
public InvHelper()
-
-
Method Details
-
find
public static int find(net.minecraft.item.Item item) Find the first slot containing an item in the entire inventory- Parameters:
item- The item to find- Returns:
- The slot index, or -1 if not found
-
find
public static int find(net.minecraft.block.Block block) Find the first slot containing a block in the entire inventory- Parameters:
block- The block to find- Returns:
- The slot index, or -1 if not found
-
find
public static int find(net.minecraft.item.Item... items) Find the first slot containing any of the specified items in the entire inventory- Parameters:
items- The items to find- Returns:
- The slot index, or -1 if not found
-
find
public static int find(net.minecraft.block.Block... blocks) Find the first slot containing any of the specified blocks in the entire inventory- Parameters:
blocks- The blocks to find- Returns:
- The slot index, or -1 if not found
-
find
Find the first slot matching the predicate in the entire inventory- Parameters:
test- The predicate to test item stacks- Returns:
- The slot index, or -1 if not found
-
findInHotbar
public static int findInHotbar(net.minecraft.item.Item item) Find the first slot containing an item in the hotbar- Parameters:
item- The item to find- Returns:
- The slot index (0-8), or -1 if not found
-
findInHotbar
public static int findInHotbar(net.minecraft.block.Block block) Find the first slot containing a block in the hotbar- Parameters:
block- The block to find- Returns:
- The slot index (0-8), or -1 if not found
-
findInHotbar
public static int findInHotbar(net.minecraft.item.Item... items) Find the first slot containing any of the specified items in the hotbar- Parameters:
items- The items to find- Returns:
- The slot index (0-8), or -1 if not found
-
findInHotbar
public static int findInHotbar(net.minecraft.block.Block... blocks) Find the first slot containing any of the specified blocks in the hotbar- Parameters:
blocks- The blocks to find- Returns:
- The slot index (0-8), or -1 if not found
-
findInHotbar
Find the first slot matching the predicate in the hotbar- Parameters:
test- The predicate to test item stacks- Returns:
- The slot index (0-8), or -1 if not found
-
swapToSlot
Swap to the specified slot using the given swap type- Parameters:
slot- The slot to swap toswapType- The swap type to use- Returns:
- true if swap was successful
-
swapToSlot
Swap to the specified slot using the given toggleable swap type- Parameters:
slot- The slot to swap toswapType- The toggleable swap type to use- Returns:
- true if swap was successful, false if Off or swap failed
-
swapBack
public static void swapBack()Swap back to the original slot
-