Class InventoryTranslator

java.lang.Object
org.geysermc.geyser.translator.inventory.InventoryTranslator
Direct Known Subclasses:
BaseInventoryTranslator, PlayerInventoryTranslator

public abstract class InventoryTranslator extends Object
  • Field Details

    • PLAYER_INVENTORY_TRANSLATOR

      public static final InventoryTranslator 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

      public abstract void prepareInventory(GeyserSession session, Inventory inventory)
    • openInventory

      public abstract void openInventory(GeyserSession session, Inventory inventory)
    • closeInventory

      public abstract void closeInventory(GeyserSession session, Inventory inventory)
    • updateProperty

      public abstract void updateProperty(GeyserSession session, Inventory inventory, int key, int value)
    • updateInventory

      public abstract void updateInventory(GeyserSession session, Inventory inventory)
    • updateSlot

      public abstract void updateSlot(GeyserSession session, Inventory inventory, int slot)
    • bedrockSlotToJava

      public abstract int bedrockSlotToJava(com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData slotInfoData)
    • javaSlotToBedrock

      public abstract int javaSlotToBedrock(int javaSlot)
    • javaSlotToBedrockContainer

      public abstract BedrockContainerSlot javaSlotToBedrockContainer(int javaSlot)
    • getSlotType

      public abstract SlotType getSlotType(int javaSlot)
    • 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)
    • 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)
    • 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)