Class InvHelper

java.lang.Object
dev.boze.api.utility.interaction.InvHelper

public class InvHelper extends Object
InvHelper provides utilities for finding items in the player's inventory

WARNING: Always swap back after swapping with silent/alt mode
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    find(Predicate<net.minecraft.item.ItemStack> test)
    Find the first slot matching the predicate in the entire inventory
    static int
    find(net.minecraft.block.Block block)
    Find the first slot containing a block in the entire inventory
    static int
    find(net.minecraft.block.Block... blocks)
    Find the first slot containing any of the specified blocks in the entire inventory
    static int
    find(net.minecraft.item.Item item)
    Find the first slot containing an item in the entire inventory
    static int
    find(net.minecraft.item.Item... items)
    Find the first slot containing any of the specified items in the entire inventory
    static int
    findInHotbar(Predicate<net.minecraft.item.ItemStack> test)
    Find the first slot matching the predicate in the hotbar
    static int
    findInHotbar(net.minecraft.block.Block block)
    Find the first slot containing a block in the hotbar
    static int
    findInHotbar(net.minecraft.block.Block... blocks)
    Find the first slot containing any of the specified blocks in the hotbar
    static int
    findInHotbar(net.minecraft.item.Item item)
    Find the first slot containing an item in the hotbar
    static int
    findInHotbar(net.minecraft.item.Item... items)
    Find the first slot containing any of the specified items in the hotbar
    static void
    Swap back to the original slot
    static boolean
    swapToSlot(int slot, SwapType swapType)
    Swap to the specified slot using the given swap type
    static boolean
    swapToSlot(int slot, ToggleableSwapType swapType)
    Swap to the specified slot using the given toggleable swap type

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static int find(Predicate<net.minecraft.item.ItemStack> test)
      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

      public static int findInHotbar(Predicate<net.minecraft.item.ItemStack> test)
      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

      public static boolean swapToSlot(int slot, SwapType swapType)
      Swap to the specified slot using the given swap type
      Parameters:
      slot - The slot to swap to
      swapType - The swap type to use
      Returns:
      true if swap was successful
    • swapToSlot

      public static boolean swapToSlot(int slot, ToggleableSwapType swapType)
      Swap to the specified slot using the given toggleable swap type
      Parameters:
      slot - The slot to swap to
      swapType - 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