Package org.geysermc.geyser.util
Class InventoryUtils
java.lang.Object
org.geysermc.geyser.util.InventoryUtils
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intStores the last used recipe network ID.static com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanStack(com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item1, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack item2)static booleancanStack(com.nukkitx.protocol.bedrock.data.inventory.ItemData item1, com.nukkitx.protocol.bedrock.data.inventory.ItemData item2)static booleancanStack(GeyserItemStack item1, GeyserItemStack item2)static voidcloseInventory(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 voiddisplayInventory(GeyserSession session, Inventory inventory)static voidfindOrCreateItem(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack itemStack)static voidfindOrCreateItem(GeyserSession session, String itemName)Attempt to find the specified item name in the session's inventory.static InventorygetInventory(GeyserSession session, int windowId)static voidopenInventory(GeyserSession session, Inventory inventory)static voidupdateCursor(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
 
 -