Class InventoryTranslator
java.lang.Object
org.geysermc.geyser.translator.inventory.InventoryTranslator
- Direct Known Subclasses:
BaseInventoryTranslator,PlayerInventoryTranslator
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponseacceptRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request, List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry> containerEntries)abstract intbedrockSlotToJava(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)booleancheckNetId(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)abstract voidcloseInventory(GeyserSession session, Inventory inventory)abstract InventorycreateInventory(String name, int windowId, com.github.steveice10.mc.protocol.data.game.inventory.ContainerType containerType, PlayerInventory playerInventory)protected voiddumpStackRequestDetails(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData source, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData destination)Print out the contents of an ItemStackRequest, should the net ID check fail.intUsed for crafting-related transactions.abstract SlotTypegetSlotType(int javaSlot)static @Nullable InventoryTranslatorinventoryTranslator(@Nullable com.github.steveice10.mc.protocol.data.game.inventory.ContainerType type)Gets theInventoryTranslatorfor the givenContainerType.protected static booleanisCursor(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)abstract intjavaSlotToBedrock(int javaSlot)abstract BedrockContainerSlotjavaSlotToBedrockContainer(int javaSlot)protected List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry>makeContainerEntries(GeyserSession session, Inventory inventory, it.unimi.dsi.fastutil.ints.IntSet affectedSlots)abstract voidopenInventory(GeyserSession session, Inventory inventory)abstract voidprepareInventory(GeyserSession session, Inventory inventory)protected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponserejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Reject an incorrect ItemStackRequest.protected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponserejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request, boolean throwError)Reject an incorrect ItemStackRequest.protected booleanshouldHandleRequestFirst(com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequestActionData action, Inventory inventory)Should be overrided if this request matches a certain criteria and shouldn't be treated normally.protected booleanshouldRejectItemPlace(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType bedrockSourceContainer, int javaSourceSlot, com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType bedrockDestinationContainer, int javaDestinationSlot)Should be overwritten in cases where specific inventories should reject an item being in a specific spot.com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponsetranslateAutoCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponsetranslateCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)protected com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponsetranslateCreativeRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Handled inPlayerInventoryTranslatorcom.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponsetranslateRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)voidtranslateRequests(GeyserSession session, Inventory inventory, List<com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest> requests)protected com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ResponsetranslateSpecialRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)IfshouldHandleRequestFirst(StackRequestActionData, Inventory)returns true, this will be calledabstract voidupdateInventory(GeyserSession session, Inventory inventory)abstract voidupdateProperty(GeyserSession session, Inventory inventory, int key, int value)abstract voidupdateSlot(GeyserSession session, Inventory inventory, int slot)
-
Field Details
-
PLAYER_INVENTORY_TRANSLATOR
-
PLAYER_INVENTORY_SIZE
public static final int PLAYER_INVENTORY_SIZE- See Also:
- Constant Field Values
-
PLAYER_INVENTORY_OFFSET
public static final int PLAYER_INVENTORY_OFFSET- See Also:
- Constant Field Values
-
size
public final int size
-
-
Constructor Details
-
InventoryTranslator
public InventoryTranslator()
-
-
Method Details
-
prepareInventory
-
openInventory
-
closeInventory
-
updateProperty
public abstract void updateProperty(GeyserSession session, Inventory inventory, int key, int value) -
updateInventory
-
updateSlot
-
bedrockSlotToJava
public abstract int bedrockSlotToJava(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData) -
javaSlotToBedrock
public abstract int javaSlotToBedrock(int javaSlot) -
javaSlotToBedrockContainer
-
getSlotType
-
createInventory
public abstract Inventory createInventory(String name, int windowId, com.github.steveice10.mc.protocol.data.game.inventory.ContainerType containerType, PlayerInventory playerInventory) -
getGridSize
public int getGridSize()Used for crafting-related transactions. Will override in PlayerInventoryTranslator and CraftingInventoryTranslator. -
shouldRejectItemPlace
protected boolean shouldRejectItemPlace(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType bedrockSourceContainer, int javaSourceSlot, com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType bedrockDestinationContainer, int javaDestinationSlot)Should be overwritten in cases where specific inventories should reject an item being in a specific spot. For examples, looms use this to reject items that are dyes in Bedrock but not in Java. The source/destination slot will be -1 if the cursor is the slot- Returns:
- true if this transfer should be rejected
-
shouldHandleRequestFirst
protected boolean shouldHandleRequestFirst(com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequestActionData action, Inventory inventory)Should be overrided if this request matches a certain criteria and shouldn't be treated normally. E.G. anvil renaming or enchanting -
translateSpecialRequest
protected com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateSpecialRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)IfshouldHandleRequestFirst(StackRequestActionData, Inventory)returns true, this will be called -
translateRequests
public final void translateRequests(GeyserSession session, Inventory inventory, List<com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest> requests) -
translateRequest
public com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request) -
translateCraftingRequest
public com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request) -
translateAutoCraftingRequest
public com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateAutoCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request) -
translateCreativeRequest
protected com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateCreativeRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Handled inPlayerInventoryTranslator -
acceptRequest
protected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response acceptRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request, List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry> containerEntries) -
rejectRequest
protected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response rejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Reject an incorrect ItemStackRequest. -
rejectRequest
protected static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response rejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request, boolean throwError)Reject an incorrect ItemStackRequest.- Parameters:
throwError- whether this request was truly erroneous (true), or known as an outcome and should not be treated as bad (false).
-
dumpStackRequestDetails
protected void dumpStackRequestDetails(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData source, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData destination)Print out the contents of an ItemStackRequest, should the net ID check fail. -
checkNetId
public boolean checkNetId(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData) -
makeContainerEntries
protected final List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry> makeContainerEntries(GeyserSession session, Inventory inventory, it.unimi.dsi.fastutil.ints.IntSet affectedSlots) -
isCursor
protected static boolean isCursor(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData) -
inventoryTranslator
public static @Nullable InventoryTranslator inventoryTranslator(@Nullable com.github.steveice10.mc.protocol.data.game.inventory.ContainerType type)Gets theInventoryTranslatorfor the givenContainerType. ReturnsPLAYER_INVENTORY_TRANSLATORif type is null.- Parameters:
type- the type- Returns:
- the InventoryType for the given ContainerType.
-