PrismarineJS / mineflayer

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

Crash while joining server on 1.8.9 #2859

Open InaayatDaDev opened 1 year ago

InaayatDaDev commented 1 year ago

Versions

Detailed description of a problem

Everytime I connect to the server I crash. Im trying to log into the server

Error:

C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\prismarine-chat\index.js:46
      if (typeof json.text === 'string' || typeof json.text === 'number') {
                      ^

TypeError: Cannot read property 'text' of null
    at ChatMessage.parse (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\prismarine-chat\index.js:46:23)
    at new ChatMessage (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\prismarine-chat\index.js:32:12)
    at Client.<anonymous> (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\mineflayer\lib\plugins\entities.js:483:32)
    at Client.emit (events.js:375:28)
    at FullPacketParser.<anonymous> (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (events.js:375:28)
    at addChunk (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:298:12)
    at readableAddChunk (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\protodef\node_modules\readable-stream\lib\_stream_readable.js:241:10)
    at FullPacketParser.Transform.push (C:\Users\Inaayat\Desktop\InaaMinemen\node_modules\protodef\node_modules\readable-stream\lib\_stream_transform.js:139:32)

What did you try yet?

Did you try any method from the API? yes Did you try any example? Any error from those? yes

Your current code


const mineflayer = require('mineflayer');
const delay = require('delay');
const mineflayer_gui = require(`mineflayer-gui`);

var settings = {
    username: "",
    host: "as.minemen.club",
    password: "",
    version: "1.8.9",
    auth: "microsoft"
}

function sleep(ms) {
    return new Promise((resolve) => {
        setTimeout(resolve, ms);
    });
}

const bot = mineflayer.createBot(settings);

//bot.loadPlugin(mineflayer_gui);

bot.once("spawn", async () => {
    console.log('Logged in to as.minemen.club');
    bot.chat('/joinqueue as-practice');
    await sleep(1000);
    console.log('Joined as-practice');
});

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

bot.on('error', (e) => { console.log('Encountered an error: ' + e) });

Expected behavior

I want to login to the server and for the bot to type /joinqueue as-practice

Additional context

nope also my English is poor sorry!

cuervotronic commented 1 year ago

Hello! i found a similar issue, Try commenting / deleting al bot.chat() I think it is a bug indeed!

When i try to send message i get:

TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length') at Object.previousMessages (eval at compile (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:258:12), <anonymous>:175:37) at Object.packet_chat_message (eval at compile (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:258:12), <anonymous>:599:37) at eval (eval at compile (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1187:64) at packet (eval at compile (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1235:9) at CompiledProtodef.sizeOf (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:89:14) at e.message (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:96:40) at tryCatch (/Users/macbook/DonBotello/node_modules/protodef/src/utils.js:50:16) at CompiledProtodef.createPacketBuffer (/Users/macbook/DonBotello/node_modules/protodef/src/compiler.js:96:20) at Serializer.createPacketBuffer (/Users/macbook/DonBotello/node_modules/protodef/src/serializer.js:12:23) at Serializer._transform (/Users/macbook/DonBotello/node_modules/protodef/src/serializer.js:18:18) { field: 'play.toServer'

InaayatDaDev commented 1 year ago

I tried but still the same error. I only get this error while connecting to minemen.club

Olfi01 commented 1 year ago

I'm getting this error whenever I'm trying to send or receive a chat message

Olfi01 commented 1 year ago

(in my case I'm trying it on a 1.19.1 server)

extremeheat commented 1 year ago

(in my case I'm trying it on a 1.19.1 server)

1.19.1 is not supported. Did you not see the pinned issue?

Olfi01 commented 1 year ago

(in my case I'm trying it on a 1.19.1 server)

1.19.1 is not supported. Did you not see the pinned issue?

I did not, and I thought it was because the npm package page explicitly says it is 1.19 compatible.

frej4189 commented 1 year ago

(in my case I'm trying it on a 1.19.1 server)

1.19.1 is not supported. Did you not see the pinned issue?

I did not, and I thought it was because the npm package page explicitly says it is 1.19 compatible.

It does support 1.19, but not 1.19.1+. There are some major differences with chat signing in particular

extremeheat commented 1 year ago

Can OP or anyone confirm this is still an issue on 1.8.9 with this server?