Class PlayerInventoryTranslator
java.lang.Object
org.geysermc.geyser.translator.inventory.InventoryTranslator<PlayerInventory>
org.geysermc.geyser.translator.inventory.PlayerInventoryTranslator
-
Nested Class Summary
Nested classes/interfaces inherited from class org.geysermc.geyser.translator.inventory.InventoryTranslator
InventoryTranslator.CraftState -
Field Summary
Fields inherited from class org.geysermc.geyser.translator.inventory.InventoryTranslator
PLAYER_INVENTORY_OFFSET, PLAYER_INVENTORY_SIZE, PLAYER_INVENTORY_TRANSLATOR, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbedrockSlotToJava(org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequestSlotData slotInfoData) Converts the Bedrock slot to the corresponding Java slot.booleancanReuseInventory(GeyserSession session, @NonNull Inventory inventory, @NonNull Inventory previous) Whether a new inventory should be prepared - or if we can re-use the previous one.voidcloseInventory(GeyserSession session, PlayerInventory inventory, boolean force) Closes the inventory, and if necessary, cleans up the prepared inventory.createInventory(GeyserSession session, String name, int windowId, org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerType containerType) Creates a new inventory.intUsed for crafting-related transactions.getSlotType(int javaSlot) Returns the slot type for a Java slot idintjavaSlotToBedrock(int slot) Converts a Java slot to the corresponding Bedrock slot.javaSlotToBedrockContainer(int slot, PlayerInventory inventory) Converts a Java slot to the corresponding Bedrock container and slotvoidopenInventory(GeyserSession session, PlayerInventory inventory) Opens the previously prepared inventory.booleanprepareInventory(GeyserSession session, PlayerInventory inventory) Prepares the inventory before opening it.protected org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponsetranslateCreativeRequest(GeyserSession session, PlayerInventory inventory, org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequest request) Handled inPlayerInventoryTranslatororg.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponsetranslateRequest(GeyserSession session, PlayerInventory inventory, org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequest request) static voidupdateCraftingGrid(GeyserSession session, PlayerInventory inventory) Update the crafting grid for the player to hide/show the barriers in the creative inventoryvoidupdateInventory(GeyserSession session, PlayerInventory inventory) Updates the inventory by re-sending items for all slots of the inventory.voidupdateProperty(GeyserSession session, PlayerInventory inventory, int key, int value) Updates a property in the inventory.voidupdateSlot(GeyserSession session, PlayerInventory inventory, int slot) Updates a specific slot by re-sending the item.Methods inherited from class org.geysermc.geyser.translator.inventory.InventoryTranslator
acceptRequest, checkNetId, dumpStackRequestDetails, inventoryTranslator, isCursor, makeContainerEntries, rejectRequest, rejectRequest, requiresOpeningDelay, shouldHandleRequestFirst, shouldRejectItemPlace, translateAutoCraftingRequest, translateCraftingRequest, translateRequests, translateSpecialRequest
-
Constructor Details
-
PlayerInventoryTranslator
public PlayerInventoryTranslator()
-
-
Method Details
-
getGridSize
public int getGridSize()Description copied from class:InventoryTranslatorUsed for crafting-related transactions. Will override in PlayerInventoryTranslator and CraftingInventoryTranslator.- Overrides:
getGridSizein classInventoryTranslator<PlayerInventory>
-
updateInventory
Description copied from class:InventoryTranslatorUpdates the inventory by re-sending items for all slots of the inventory.- Specified by:
updateInventoryin classInventoryTranslator<PlayerInventory>
-
updateCraftingGrid
Update the crafting grid for the player to hide/show the barriers in the creative inventory- Parameters:
session- Connection of the playerinventory- Inventory of the player
-
updateSlot
Description copied from class:InventoryTranslatorUpdates a specific slot by re-sending the item.- Specified by:
updateSlotin classInventoryTranslator<PlayerInventory>
-
bedrockSlotToJava
public int bedrockSlotToJava(org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequestSlotData slotInfoData) Description copied from class:InventoryTranslatorConverts the Bedrock slot to the corresponding Java slot.- Specified by:
bedrockSlotToJavain classInventoryTranslator<PlayerInventory>
-
javaSlotToBedrock
public int javaSlotToBedrock(int slot) Description copied from class:InventoryTranslatorConverts a Java slot to the corresponding Bedrock slot.- Specified by:
javaSlotToBedrockin classInventoryTranslator<PlayerInventory>
-
javaSlotToBedrockContainer
Description copied from class:InventoryTranslatorConverts a Java slot to the corresponding Bedrock container and slot- Specified by:
javaSlotToBedrockContainerin classInventoryTranslator<PlayerInventory>
-
getSlotType
Description copied from class:InventoryTranslatorReturns the slot type for a Java slot id- Specified by:
getSlotTypein classInventoryTranslator<PlayerInventory>
-
translateRequest
public org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponse translateRequest(GeyserSession session, PlayerInventory inventory, org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequest request) - Overrides:
translateRequestin classInventoryTranslator<PlayerInventory>
-
translateCreativeRequest
protected org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponse translateCreativeRequest(GeyserSession session, PlayerInventory inventory, org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.ItemStackRequest request) Description copied from class:InventoryTranslatorHandled inPlayerInventoryTranslator- Overrides:
translateCreativeRequestin classInventoryTranslator<PlayerInventory>
-
createInventory
public PlayerInventory createInventory(GeyserSession session, String name, int windowId, org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerType containerType) Description copied from class:InventoryTranslatorCreates a new inventory.- Specified by:
createInventoryin classInventoryTranslator<PlayerInventory>
-
canReuseInventory
public boolean canReuseInventory(GeyserSession session, @NonNull Inventory inventory, @NonNull Inventory previous) Description copied from class:InventoryTranslatorWhether a new inventory should be prepared - or if we can re-use the previous one.- Overrides:
canReuseInventoryin classInventoryTranslator<PlayerInventory>
-
prepareInventory
Description copied from class:InventoryTranslatorPrepares the inventory before opening it. Bedrock requires the inventory to "exist" before opening it - that can be either a real block (e.g. chest), or an entity (e.g. horse)- Specified by:
prepareInventoryin classInventoryTranslator<PlayerInventory>- Returns:
- whether the inventory was successfully prepared
-
openInventory
Description copied from class:InventoryTranslatorOpens the previously prepared inventory.- Specified by:
openInventoryin classInventoryTranslator<PlayerInventory>
-
closeInventory
Description copied from class:InventoryTranslatorCloses the inventory, and if necessary, cleans up the prepared inventory.- Specified by:
closeInventoryin classInventoryTranslator<PlayerInventory>
-
updateProperty
Description copied from class:InventoryTranslatorUpdates a property in the inventory.- Specified by:
updatePropertyin classInventoryTranslator<PlayerInventory>
-