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

Error when entering the nether #729

Closed derjp closed 5 years ago

derjp commented 6 years ago

Whenever the bot enters the nether I get following error:

buffer.js:972
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range
    at checkOffset (buffer.js:972:11)
    at Buffer.readUInt8 (buffer.js:1010:5)
    at readUInt4LE (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\uint4\index.js:21:23)
    at Section.getSkyLight (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\section.js:84:12)
    at Chunk.getSkyLight (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:120:34)
    at Chunk.getBlock (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:74:27)
    at Bot.blockAt (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\blocks.js:91:26)
    at nextFrame (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\physics.js:132:28)
    at Timeout.doPhysics [as _onTimeout] (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\physics.js:54:5)
    at ontimeout (timers.js:475:11)

It's a non-vanilla (paper) server. Any fix for this? Thanks

rom1504 commented 6 years ago

What Minecraft version ?

On Thu, Oct 18, 2018, 17:19 DERJP notifications@github.com wrote:

Whenever the bot enters the nether I get following error:

`buffer.js:972 throw new RangeError('Index out of range'); ^

RangeError: Index out of range at checkOffset (buffer.js:972:11) at Buffer.readUInt8 (buffer.js:1010:5) at readUInt4LE (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\uint4\index.js:21:23) at Section.getSkyLight (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\section.js:84:12) at Chunk.getSkyLight (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:120:34) at Chunk.getBlock (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:74:27) at Bot.blockAt (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\blocks.js:91:26) at nextFrame (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\physics.js:132:28) at Timeout.doPhysics [as _onTimeout] (C:\Users\JP\Projects\gg-bot-witherfarm\node_modules\mineflayer\lib\plugins\physics.js:54:5) at ontimeout (timers.js:475:11)`

It's a non-vanilla (spigot) server. Any fix for this? Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/729, or mute the thread https://github.com/notifications/unsubscribe-auth/ACPN_tVqt_VzEsqm-A4Q2NaFNjBn7sm0ks5umJvmgaJpZM4XtrRR .

derjp commented 6 years ago

1.8

skullteria commented 5 years ago

I also experienced problems today when attempting to go/tp into the nether on a non-vanilla server with 1.8.9 client. The server is compatible with clients up to 12.X but 1.8.9 is recommended. I was able to reproduce the error on a local 1.8.8 and 1.8.9 vanilla server with the exact same exception at the same place in code at the same moment in game. Newer client versions from 1.9 upwards had no problem with the nether. I have the latest commit from the master branch of mineflayer and simply ran npm install for the rest. This is my config for the bot when I connected to the server:

const bot = mineflayer.createBot({
  host: process.argv[2],
  port: parseInt(process.argv[3]),
  username: process.argv[4] ? process.argv[4] : 'echo',
  password: process.argv[5],
  version: '1.8.9',
  verbose: true
})

This is the exception I received while the bot tried to load the chunks:

internal/buffer.js:53
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 10239. Received 11953
    at boundsError (internal/buffer.js:53:9)
    at Buffer.readUInt8 (internal/buffer.js:141:5)
    at readUInt4LE (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\uint4\index.js:23:23)
    at Section.getSkyLight (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\prismarine-chunk\src\pc\1.8\section.js:81:12)
    at Chunk.getSkyLight (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:112:34)
    at Chunk.getBlock (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:71:27)
    at Bot.blockAt (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\mineflayer\lib\plugins\blocks.js:97:26)
    at nextFrame (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\mineflayer\lib\plugins\physics.js:133:28)
    at Timeout.doPhysics [as _onTimeout] (E:\Programs\Portable\EclipsePortable\Data\workspace\testBot\node_modules\mineflayer\lib\plugins\physics.js:55:5)
    at ontimeout (timers.js:436:11)

The only thing that wasn't same in every Exception was the received "offset" value, but I guess different chunk different chunk size, but in the end it was always bigger than it should be.

There seems to be some problem with the protocol implementation of the 1.8.X version when considering the chunks in the nether.

rom1504 commented 5 years ago

this is now solved thanks to a PR from @skullteria in prismarine-chunk to get the fix, just run npm update