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

The value of "offset" is out of range. #2891

Closed EaterAS closed 1 year ago

EaterAS commented 1 year ago

Versions

Detailed description of a problem

I have a faction bot running on the server and it shows the offset error everytime i try to move to a different location and even if it don't move it, after some time it will show the error regardless. This only seems to happen when the account has a rank.

What did you try yet?

I am not really sure what to try

Did you try any method from the API? No

Did you try any example? Any error from those? No

Your current code

var bot = mineflayer.createBot(b);
bindEvents(bot);

function bindEvents(bot) {
    bot.once('login', () => {
        database.toggleBotRestarting(false);
        bot.settings.viewDistance = 'tiny';
        bot.settings.colorsEnabled = false;

        console.log(bot.username + ' has connected to ' + config.serverip + '.')
        bot.chat('/login ' + config.password)
        options.wait(options.minuteToMS / 12).then(() => {
            bot.chat(database.getString('joincmd'));
        })
    });

    bot.on('kicked', (reason, loggedIn) => {
        console.log(reason, loggedIn);
        serverChat.push(JSON.parse(reason).text.replace(/\u00A7[0-9A-FK-OR]/ig, ''));
        bot.quit();
    });

    bot.on('end', () => {
        restart();
    });

    bot.on('error', (err) => { console.log(err) });
};

Additional context

This is the error i get

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 10239. Received 11629
    at new NodeError (node:internal/errors:393:5)
    at boundsError (node:internal/buffer:86:9)
    at Buffer.readUInt8 (node:internal/buffer:252:5)
    at readUInt4LE (/home/container/node_modules/uint4/index.js:23:23)
    at writeUInt4LE (/home/container/node_modules/uint4/index.js:34:28)
    at Section.setSkyLight (/home/container/node_modules/prismarine-chunk/src/pc/1.8/section.js:123:5)
    at Chunk.setSkyLight (/home/container/node_modules/prismarine-chunk/src/pc/1.8/chunk.js:145:33)
    at Chunk.setBlock (/home/container/node_modules/prismarine-chunk/src/pc/1.8/chunk.js:79:42)
    at Client.<anonymous> (/home/container/node_modules/mineflayer/lib/plugins/blocks.js:406:12)
    at Client.emit (node:events:513:28) {
  code: 'ERR_OUT_OF_RANGE'
} uncaughtException
EaterAS commented 1 year ago

https://pastebin.com/RGzPXwYn

This is what i got from minecraft-protocol debugging

CZakarya commented 1 year ago

Having a specific function for "binding events" is undesirable and will often break with namespaces. I know it seems like a good idea to separate it, but it makes things harder down the road with code complexity. You are also calling the bindEvents function before defining it. This may work with the specific JavaScript interpreter you are using, but most interpreters will throw an undefined error.

EaterAS commented 1 year ago

Having a specific function for "binding events" is undesirable and will often break with namespaces. I know it seems like a good idea to separate it, but it makes things harder down the road with code complexity. You are also calling the bindEvents function before defining it. This may work with the specific JavaScript interpreter you are using, but most interpreters will throw an undefined error.

dont think thats the reason for the error, it shows that even with a normal bot

MightyPiggie commented 1 year ago

Are you in the nether by any change? There seem to a issue on 1.8 with block updates:

2614

extremeheat commented 1 year ago

Dupe #2614

EaterAS commented 1 year ago

Are you in the nether by any change? There seem to a issue on 1.8 with block updates: #2614

nope, just normal overworld i believe