Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after updating bot to 1.21.1 #3488

Open
1 task done
i240c opened this issue Oct 27, 2024 · 1 comment
Open
1 task done

Error after updating bot to 1.21.1 #3488

i240c opened this issue Oct 27, 2024 · 1 comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@i240c
Copy link

i240c commented Oct 27, 2024

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.23.0
  • server: paper 1.21.1
  • node: 20.13.1

Detailed description of a problem

Tried joining my minecraft server after updating to 1.21 but for some reason gave an error so I made a fresh project with just join code but it still gave the same error. The bot worked in the server on previous version.

What did you try yet?

I have no idea what causes it so I don't know what to try

Your current code

import mineflayer from "mineflayer";
import chalk from "chalk";
import { readFile } from 'fs/promises';

// Setup global bot arguments
let botArgs = {
    host: 'hiddenIpAddress',
    port: '25565',
    version: '1.21.1'
};

// Bot class
class MCBot {

    // Constructor
    constructor(username, password, auth) {
        this.username = username;
        this.password = password;
        this.auth = auth;
        this.host = botArgs["host"];
        this.port = botArgs["port"];
        this.version = botArgs["version"];

        // Initialize the bot
        this.initBot();
    }

    // Init bot instance
    initBot() {
        this.bot = mineflayer.createBot({
           // "username": this.username,
          //  "password": this.password,
            "auth": this.auth,
            "host": this.host,
            "port": this.port,
            "version": this.version
        });

        // Add to list
        botNames.push(this.bot.username);

        // Initialize bot events
        this.initEvents();
    }

    // Logger
    log(...msg) {
        console.log(`[${this.bot.username}]`, ...msg);
    }

    // Chat intake logger
    chatLog(username, ...msg) {
        if (!botNames.includes(username)) {
            this.log(chalk.ansi256(98)(`<${username}>`), ...msg)
        }
    }

    // Init bot events
    initEvents() {

        this.bot.on('login', async () => {
            let botSocket = this.bot._client.socket;
            this.log(chalk.ansi256(34)(`Logged in to ${botSocket.server ? botSocket.server : botSocket._host}`));
        });

        this.bot.on('end', async (reason) => {
            this.log(chalk.red(`Disconnected: ${reason}`));

            // Bot peacefully disconnected
            if (reason == "disconnect.quitting") {
                return
            }
            // Unhandled disconnections
            else {
                //
            }

            // Attempt to reconnect
            setTimeout(() => this.initBot(), 5000);
        });

        this.bot.on('spawn', async () => {
            this.log(chalk.ansi256(46)(`Spawned in`));
        });

        this.bot.on('chat', async (username, jsonMsg) => {
            this.chatLog(username, jsonMsg);
        });

        this.bot.on('error', async (err) => {

            // Connection error
            if (err.code == 'ECONNREFUSED') {
                this.log(`Failed to connect to ${err.address}:${err.port}`)
            }
            // Unhandled errors
            else {
                this.log(`Unhandled error: ${err}`);
            }
        });
    }
}

const ACCOUNT = JSON.parse(
    await readFile(
        new URL('./ACCOUNT.json', import.meta.url)
    )
);

let bots = [];
let botNames = [];
for (const ACC of ACCOUNT) {
    let newBot = new MCBot(ACC.username, ACC.password, ACC.auth)
    bots.push(newBot);
};

/*
Error code

Error: Read error for undefined : Invalid tag: 117 > 20
    at Object.compound (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:16:21)
    at Object.nbtSwitch (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:4310:47)
    at Object.anonymousNbt (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:77:64)
    at eval (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:136:56)
    at Object.SlotComponent (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:729:9)
    at eval (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:748:49)
    at eval (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:753:15)
    at eval (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:771:13)
    at Object.Slot (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:773:9)
    at Object.ingredient (eval at compile (C:\Users\240c\source\repos\KohukeExpress\node_modules\protodef\src\compiler.js:262:12), <anonymous>:998:32) {
  field: 'play.toClient'
}

*/


## Expected behavior
The bot should just join the server and stay there

@i240c i240c added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Oct 27, 2024
@rom1504
Copy link
Member

rom1504 commented Oct 27, 2024

Ok something wrong with SlotComponent and paper server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

2 participants