Skip to content

JEI recipe transfer kicks player with "Illegal packet received" when server has no JEI (1.3.80) #500

Description

@skrhold

Mod versions:

  • Minecraft 1.20.1, Forge 47.4.21
  • Sophisticated Core 1.3.80.2267
  • Sophisticated Backpacks 3.24.66.2095
  • JEI 15.20.0.134 (client only)

How to reproduce:

  1. Client has JEI installed; dedicated server does NOT have JEI (common setup).
  2. Player opens a backpack's Crafting Upgrade GUI and clicks a recipe in JEI to transfer ingredients into the crafting grid.
  3. Player is instantly disconnected. Server log:
    [ServerGamePacketListenerImpl]: lost connection: Illegal packet received, terminating connection

Root cause (from bytecode analysis of 1.3.80):

  • ModCompat.initCompats() gates compat setup on ModList.isLoaded("jei") / ("roughlyenoughitems") / ("emi").
  • JeiCompat.setup() registers JeiTransferRecipeMessage (PLAY_TO_SERVER) and then CommonMessages.registerMessages() registers SetGhostSlotMessage / SetMemorySlotMessage (both PLAY_TO_SERVER).
  • These are client->server messages that the server MUST be able to receive, but registration is tied to whether THIS instance has JEI. On a server without JEI they are never registered, so the SimpleChannel message indexes drift between client and server. When the client sends JeiTransferRecipeMessage, the server decodes it at the wrong index and NetworkHooks.validatePacketDirection / validateSideForProcessing rejects it.

Additional context:

  • In 1.3.78 the same action produced: io.netty.handler.codec.EncoderException: java.io.EOFException: fieldSize is too long! Length is 4717/27497, but maximum is ~500. The old decode used readMap/readList with no max, overrunning the buffer. 1.3.80 added PacketBufferHelper.readList/readMap with caps (9/9/512), which fixed the overflow but moved the transfer-message registration behind the JEI-load check, introducing this index misalignment.

Suggested fix:

  • Register JeiTransferRecipeMessage, SetGhostSlotMessage and SetMemorySlotMessage unconditionally (they are PLAY_TO_SERVER messages and must exist on both sides), or at least always register them server-side regardless of whether JEI/REI/EMI is installed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions