PrismarineJS / mineflayer

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

TypeError: Cannot set properties of undefined (setting 'height') #2730

Closed ufgf closed 1 year ago

ufgf commented 2 years ago

Versions

Detailed description of a problem

When passing the server "checking", clientbound parameters are set too early(?), what causes an unhandled exception:

C:\Users\ufgf\node_modules\minecraft-protocol\src\transforms\framing.js:67
          } else { throw e }
                   ^

TypeError: Cannot set properties of undefined (setting 'height')
    at Client.<anonymous> (C:\Users\ufgf\node_modules\mineflayer\lib\plugins\physics.js:260:23)
    at Client.emit (node:events:390:28)
    at FullPacketParser.<anonymous> (C:\Users\ufgf\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (node:events:390:28)
    at addChunk (C:\Users\ufgf\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:298:12)
    at readableAddChunk (C:\Users\ufgf\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (C:\Users\ufgf\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:241:10)    at FullPacketParser.Transform.push (C:\Users\ufgf\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:139:32)
    at FullPacketParser._transform (C:\Users\ufgf\node_modules\protodef\src\serializer.js:89:10)
    at FullPacketParser.Transform._read (C:\Users\ufgf\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:177:10)

Node.js v17.1.0

What did you try yet?

Connect to other servers, and make sure that the problem repeats itself when connecting only to this one

Your current code

const mineflayer = require("mineflayer");

const options = {
  host: "mc.reallyworld.ru",
  port: "25565",
  username: "some_nick",
  version: "1.12.2",
  checkTimeoutInterval: 60000,
};

var bot = mineflayer.createBot(options);
bot.setMaxListeners(0);
themain();

function themain() {
  bot.on("spawn", () => {
    bot.waitForTicks(60);
    console.log("bot.game.levelType: " + bot.game.levelType);
    bot.end();
  });

  bot.on("kicked", (reason) => {
    console.log("bot was kicked: " + reason);
    bot.end();
  });
}

Expected behavior

The bot at least executes console.log() in bot.on("spawn" ... ) or bot.on("kicked" ... )

amoraschi commented 2 years ago

Have you tried removing checkTimeoutInterval and bot.setMaxListeners(0)?

ufgf commented 2 years ago

Have you tried removing checkTimeoutInterval and bot.setMaxListeners(0)?

Does not affect the reproducibility of the problem (see video)

https://user-images.githubusercontent.com/29230208/185623435-4a2f474b-1803-40be-a5ce-e8d3fd6f7a4b.mp4

extremeheat commented 1 year ago

Reopen if it's still an issue after npm update --depth 9999