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 com.github.steveice10.mc.protocol.data.game.entity.metadata.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 windowId, boolean confirm)
    • getInventory

      public static Inventory getInventory(GeyserSession session, int windowId)
    • updateCursor

      public static void updateCursor(GeyserSession session)
    • canStack

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

      public static boolean canStack(com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item1, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item2)
    • canStack

      public static boolean canStack(com.nukkitx.protocol.bedrock.data.inventory.ItemData item1, com.nukkitx.protocol.bedrock.data.inventory.ItemData item2)
    • createUnusableSpaceBlock

      public static IntFunction<com.nukkitx.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
    • findOrCreateItem

      public static void findOrCreateItem(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack itemStack)
      See findOrCreateItem(GeyserSession, String). This is for finding a specified ItemStack.
      Parameters:
      session - the Bedrock client's session
      itemStack - the item to try to find a match for. NBT will also be accounted for.
    • findOrCreateItem

      public static void findOrCreateItem(GeyserSession session, String itemName)
      Attempt to find the specified item name in the session's inventory. If it is found and in the hotbar, set the user's held item to that slot. If it is found in another part of the inventory, move it. If it is not found and the user is in creative mode, create the item, overriding the current item slot if no other hotbar slots are empty, or otherwise selecting the empty slot. This attempts to mimic Java Edition behavior as best as it can.
      Parameters:
      session - the Bedrock client's session
      itemName - the Java identifier of the item to search/select