Package org.geysermc.geyser.util
Class InventoryUtils
java.lang.Object
org.geysermc.geyser.util.InventoryUtils
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Stores the last used recipe network ID.static com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canStack(com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item1, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item2)
static boolean
canStack(com.nukkitx.protocol.bedrock.data.inventory.ItemData item1, com.nukkitx.protocol.bedrock.data.inventory.ItemData item2)
static boolean
canStack(GeyserItemStack item1, GeyserItemStack item2)
static void
closeInventory(GeyserSession session, int windowId, boolean confirm)
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.static void
displayInventory(GeyserSession session, Inventory inventory)
static void
findOrCreateItem(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack itemStack)
static void
findOrCreateItem(GeyserSession session, String itemName)
Attempt to find the specified item name in the session's inventory.static Inventory
getInventory(GeyserSession session, int windowId)
static void
openInventory(GeyserSession session, Inventory inventory)
static void
updateCursor(GeyserSession session)
-
Field Details
-
LAST_RECIPE_NET_ID
public static int LAST_RECIPE_NET_IDStores 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
-
displayInventory
-
closeInventory
-
getInventory
-
updateCursor
-
canStack
-
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)SeefindOrCreateItem(GeyserSession, String)
. This is for finding a specifiedItemStack
.- Parameters:
session
- the Bedrock client's sessionitemStack
- the item to try to find a match for. NBT will also be accounted for.
-
findOrCreateItem
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 sessionitemName
- the Java identifier of the item to search/select
-