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

[BUG] Error: Feature undefined doesn't exist #2807

Closed OscarNOW closed 1 year ago

OscarNOW commented 2 years ago

Versions

Detailed description of a problem

When joining the bot to my 1.16.3 server, the bot produces an error.

C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\prismarine-registry\node_modules\minecraft-data\lib\supportsFeature.js:7
        throw new Error(`Feature ${feature} doesn't exist`)
        ^

Error: Feature undefined doesn't exist
    at isFeatureInRange (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\prismarine-registry\node_modules\minecraft-data\lib\supportsFeature.js:7:15)
    at EventEmitter.nmcData.supportFeature (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\prismarine-registry\node_modules\minecraft-data\index.js:71:39)
    at handleRespawnPacketData (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\mineflayer\lib\plugins\game.js:43:13)
    at Client.<anonymous> (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\mineflayer\lib\plugins\game.js:71:5)
    at Client.emit (node:events:525:35)
    at FullPacketParser.<anonymous> (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (node:events:513:28)
    at addChunk (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\readable-stream\lib\_stream_readable.js:298:12)
    at readableAddChunk (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\readable-stream\lib\_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (C:\Users\oscar\Desktop\Programmeren\minecraft-server\node_modules\readable-stream\lib\_stream_readable.js:241:10)

Your current code

const bot = mineflayer.createBot({
    host: 'localhost',
    username: credentials.username,
    password: credentials.password,
    auth: 'microsoft',
    version: '1.16.3'
})

Expected behavior

No error.

Possible issues in mineflayer code

I've looked around in the mineflayer code and I think I've found the problem. In /lib/plugins/game.js:43:

    if (bot.supportFeature('dimensionDataInCodec')) { // 1.19+

the code is checking if the dimensionDataInCodec feature is supported, but in @minecraft-data/data/pc/common/features.json there is no dimensionDataInCodec feature.

extremeheat commented 1 year ago

Update your dependencies.

npm update --depth 9999
Sceat commented 1 year ago

in my case even tho I use 1.16.5, that bug is because minecraft-data from mineflayer is not up-to-date and doesn't contain 1.19 features like dimensionDataInCodec while here https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/game.js#L43 it does

extremeheat commented 1 year ago

@Sceat that's a problem on your side. mineflayer does not use a fixed version of mcdata

Sceat commented 1 year ago

Indeed, I was using a earlier protocol version for typings compatibility and it caused mineflayer to have it's own version of the protocol but not of the datas, which kept using my own. I ended up bumping everything and i'll deal with the typings