Class InventoryTranslator
java.lang.Object
org.geysermc.geyser.translator.inventory.InventoryTranslator
- Direct Known Subclasses:
BaseInventoryTranslator
,PlayerInventoryTranslator
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic Map<com.github.steveice10.mc.protocol.data.game.inventory.ContainerType,InventoryTranslator>
static int
static int
static InventoryTranslator
int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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)
abstract int
bedrockSlotToJava(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)
boolean
checkNetId(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)
abstract void
closeInventory(GeyserSession session, Inventory inventory)
abstract Inventory
createInventory(String name, int windowId, com.github.steveice10.mc.protocol.data.game.inventory.ContainerType containerType, PlayerInventory playerInventory)
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.abstract SlotType
getSlotType(int javaSlot)
protected static boolean
isCursor(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)
abstract int
javaSlotToBedrock(int javaSlot)
abstract BedrockContainerSlot
javaSlotToBedrockContainer(int javaSlot)
List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry>
makeContainerEntries(GeyserSession session, Inventory inventory, Set<Integer> affectedSlots)
static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ItemEntry
makeItemEntry(GeyserSession session, int bedrockSlot, GeyserItemStack itemStack)
abstract void
openInventory(GeyserSession session, Inventory inventory)
abstract void
prepareInventory(GeyserSession session, Inventory inventory)
static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
rejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)
Reject an incorrect ItemStackRequest.static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
rejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request, boolean throwError)
Reject an incorrect ItemStackRequest.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.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.com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
translateAutoCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)
com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
translateCraftingRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)
com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
translateCreativeRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)
Handled inPlayerInventoryTranslator
com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response
translateRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)
void
translateRequests(GeyserSession session, Inventory inventory, List<com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest> requests)
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 calledabstract void
updateInventory(GeyserSession session, Inventory inventory)
abstract void
updateProperty(GeyserSession session, Inventory inventory, int key, int value)
abstract void
updateSlot(GeyserSession session, Inventory inventory, int slot)
-
Field Details
-
PLAYER_INVENTORY_TRANSLATOR
-
INVENTORY_TRANSLATORS
public static final Map<com.github.steveice10.mc.protocol.data.game.inventory.ContainerType,InventoryTranslator> INVENTORY_TRANSLATORS -
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(int size)
-
-
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) -
shouldRejectItemPlace
public 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
public 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
public 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 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
public com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response translateCreativeRequest(GeyserSession session, Inventory inventory, com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Handled inPlayerInventoryTranslator
-
acceptRequest
public 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
public static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.Response rejectRequest(com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest request)Reject an incorrect ItemStackRequest. -
rejectRequest
public 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
public List<com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ContainerEntry> makeContainerEntries(GeyserSession session, Inventory inventory, Set<Integer> affectedSlots) -
makeItemEntry
public static com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket.ItemEntry makeItemEntry(GeyserSession session, int bedrockSlot, GeyserItemStack itemStack) -
isCursor
protected static boolean isCursor(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)
-