PrismarineJS / mineflayer

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

TypeError [ERR_INVALID_ARG_TYPE]: Serialization error for play.toServer : SizeOf error for undefined : The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined #2555

Open ErfinderLabyrinth opened 2 years ago

ErfinderLabyrinth commented 2 years ago

Versions

Detailed description of a problem

TypeError [ERR_INVALID_ARG_TYPE]: Serialization error for play.toServer : SizeOf error for undefined : The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined at new NodeError (node:internal/errors:372:5) at Function.byteLength (node:buffer:735:11) at Object.string (eval at compile (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:259:12), :44:25) at Object.packet_custom_payload (eval at compile (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:259:12), :514:27) at eval (eval at compile (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:259:12), :842:68) at packet (eval at compile (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:259:12), :873:9) at CompiledProtodef.sizeOf (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:89:14) at e.message (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:96:40) at tryCatch (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\utils.js:50:16) at CompiledProtodef.createPacketBuffer (C:\Users\Test.DESKTOP-418PPE3\Downloads\Afk-Bot1\node_modules\protodef\src\compiler.js:96:20) { code: 'ERR_INVALID_ARG_TYPE', field: 'play.toServer' }

What did you try yet?

I have reinstalled protodef, I have reinstalled all modules

Your current code


const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  host: 'localhost', // minecraft server ip
  username: '####@####.####', // minecraft username
  password: '####' // minecraft password, comment out if you want to log into online-mode=false servers
  port: 42002,                // only set if you need a port that isn't 25565
  // version: false,             // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
  auth: 'microsoft'              // only set if you need microsoft auth, then set this to 'microsoft'
})

bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

// Log errors and kick reasons:
bot.on('kicked', console.log)
bot.on('error', console.log)

Expected behavior

The bot joined the server

rom1504 commented 2 years ago

print message before sending it, it seems like it's not right

ErfinderLabyrinth commented 2 years ago

Der Fehler ist bis jetzt nicht mehr gekommen