node-minecraft-protocol: Failed to decode packet cookie_request

[x] The FAQ doesn’t contain a resolution to my issue

Versions

  • minecraft-protocol: 1.55.0
  • server: vanilla/spigot/paper 1.21.4
  • node: 22.14.0

Detailed description of a problem

I’m trying to set up a simple offline-mode server that (currently) only spawns the player in a void world. The following code works for other versions (tested for 1.8 with slight adaptations to the login packet, 1.18, 1.19 and 1.20 with the same code, different data versions). Attempting to run the same code with 1.21 results in the connection being lost and the following error being shown:

Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'clientbound/minecraft:cookie_request'.

Current code

const mc = require("minecraft-protocol")
const mcData = require("minecraft-data")("1.21")

const server = mc.createServer({
  host: "127.0.0.1",
  port: 25565,
  version: "1.21",
  "online-mode": false,
})

server.on("login", (client) => {
  const p = mcData.loginPacket
  console.log(p)
  client.write("login", {
    ...p,
  })
  client.write("position", {
    x: 0,
    y: 0,
    z: 0,
    yaw: 0,
    pitch: 0,
  })
})

Expected behavior

The client should spawn in an empty world at the coordinates 0/0/0 immediately upon joining the server.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 24 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Ah i see, ig im just gonna have to settle with just “Disconnected”, appreciate your detailed insight into this

@HumanDuck23 did you find any fix for it? I’m on 1.21.4, trying to do client.end("<reason>") in the playerJoin event and also got the same Network Protocol Error

update: client.end("") worked, passing an empty string as the parameter. In minecraft it showed “Disconnected”. The same error persists if I added characters with spaces like client.end("Server is still starting...")

@HumanDuck23 did you find any fix for it? I’m on 1.21.4, trying to do client.end("<reason>") in the playerJoin event and also got the same Network Protocol Error

login event is too early

For 1.21 you need other packets as well iirc

But generally if you want something that works across version that’s what we built at flying-squid. You can read the code there if you want