Class InventoryUtils

java.lang.Object
org.geysermc.geyser.util.InventoryUtils

public class InventoryUtils extends Object
  • Field Details

    • LAST_RECIPE_NET_ID

      public static int LAST_RECIPE_NET_ID
      Stores the last used recipe network ID. Since 1.16.200 (and for server-authoritative inventories), each recipe needs a unique network ID (or else in .200 the client crashes).
    • REFRESH_ITEM

      public static final org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack REFRESH_ITEM
  • Constructor Details

    • InventoryUtils

      public InventoryUtils()
  • Method Details

    • openInventory

      public static void openInventory(GeyserSession session, Inventory inventory)
    • displayInventory

      public static void displayInventory(GeyserSession session, Inventory inventory)
    • closeInventory

      public static void closeInventory(GeyserSession session, int javaId, boolean confirm)
    • getInventory

      public static @Nullable Inventory getInventory(GeyserSession session, int javaId)
    • findAvailableWorldSpace

      public static @Nullable org.cloudburstmc.math.vector.Vector3i findAvailableWorldSpace(GeyserSession session)
      Finds a usable block space in the world to place a fake inventory block, and returns the position.
    • updateCursor

      public static void updateCursor(GeyserSession session)
    • canStack

      public static boolean canStack(GeyserItemStack item1, GeyserItemStack item2)
    • isEmpty

      @Contract("null -> true") public static boolean isEmpty(@Nullable org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack itemStack)
      Checks to see if an item stack represents air or has no count.
    • createUnusableSpaceBlock

      public static IntFunction<org.cloudburstmc.protocol.bedrock.data.inventory.ItemData> createUnusableSpaceBlock(String description)
      Returns a barrier block with custom name and lore to explain why part of the inventory is unusable.
      Parameters:
      description - the description
      Returns:
      the unusable space block
    • getUpgradeTemplate

      public static IntFunction<org.cloudburstmc.protocol.bedrock.data.inventory.ItemData> getUpgradeTemplate()
    • getTotemOfUndying

      public static IntFunction<org.cloudburstmc.protocol.bedrock.data.inventory.ItemData> getTotemOfUndying()
    • getClickForHotbarSwap

      public static @Nullable Click getClickForHotbarSwap(int slot)
    • acceptsAsInput

      public static boolean acceptsAsInput(GeyserSession session, org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay slotDisplay, GeyserItemStack itemStack)
      Returns if the provided item stack would be accepted by the slot display.
    • getValidRecipe

      public static @Nullable GeyserRecipe getValidRecipe(GeyserSession session, @Nullable org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack output, IntFunction<GeyserItemStack> inventoryGetter, int gridDimensions, int firstRow, int height, int firstCol, int width)
      Test all known recipes to find a valid match
      Parameters:
      output - if not null, the recipe has to output this item