PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
5.08k stars 921 forks source link

"TypeError: cannot read property 'id' of undefined", possible is bug with spectator mode #920

Closed KBenster closed 3 years ago

KBenster commented 4 years ago

Versions

Node version: 8.10.0 Server: 1.12.2 paperspigot Mineflayer 3.5.2

Error

Running on an Ubuntu VPS, connecting to a server that has players initially in spectator mode. Connecting to the server returns the following error:

`Chunk size is 73 but only 41 was read ; partial packet : {"name":"named_sound_effect","params":{"soundName":"minecraft:register","soundCategory":108,"x":1701273955,"y":2033870445,"z":1811967077,"volume":1.064367405277846e+24,"pitch":0.000879010884091258}}; buffer :19126d696e6563726166743a72656769737465726c65676163793a666d6c006c65676163793a666d6c7c6873006c65676163793a666f7267650062756e676565636f72643a6d61696e
Chunk size is 55 but only 6 was read ; partial packet : {"name":"entity_status","params":{"entityId":897262179,"entityStatus":111}}; buffer :1b357b22636f6c6f72223a22676f6c64222c2274657874223a22536572766572206973206f6e2076657273696f6e20312e31322e32227d
/mineflayer/node_modules/minecraft-protocol/src/transforms/framing.js:67
          } else { throw e }
                   ^

TypeError: Cannot read property 'id' of undefined
    at Client.bot._client.on (/mineflayer/node_modules/mineflayer/lib/plugins/inventory.js:29:40)
    at emitTwo (events.js:131:20)
    at Client.emit (events.js:214:7)
    at FullPacketParser.deserializer.on (/mineflayer/node_modules/minecraft-protocol/src/client.js:87:12)
    at emitOne (events.js:116:13)
    at FullPacketParser.emit (events.js:211:7)
    at addChunk (/mineflayer/node_modules/readable-stream/lib/_stream_readable.js:298:12)
    at readableAddChunk (/mineflayer/node_modules/readable-stream/lib/_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (/mineflayer/node_modules/readable-stream/lib/_stream_readable.js:241:10)
    at FullPacketParser.Transform.push (/mineflayer/node_modules/readable-stream/lib/_stream_transform.js:139:32)
`

Current code

Only the code to create and connect the bot. No actions regarding inventory, movement, chat, or any other aspect of the game being used other than the initial connection to the server.

const bot = mineflayer.createBot({host: process.argv[2], port: parseInt(process.argv[3]), username: process.argv[4], password: process.argv[5]})

Expected behavior

The bot itself is simply meant to connect to the server. It seems to be trying to read an inventory when there is none (player is in spectator mode when connected).

rom1504 commented 4 years ago

not possible to investigate, it's needed to have at least the server

KBenster commented 4 years ago

It was connecting to 2b2t.org. Upon connection, you are put into a queue server that holds the player in spectator mode in an end dimension. There are no blocks, and should be no players in the world while in the queue server.

rom1504 commented 3 years ago

too random, reopen if you have more information