mineflayer
mineflayer copied to clipboard
can't connect to offline server with resource pack
- [x] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: 4.20.1
- server: paper 1.20.4
- node: 20.0.0
Detailed description of a problem
I am trying to make a bot to AFK for me on an offline server with a login plugin. The server has a custom resource pack. When I connect, the bot first has to deny the resource pack, and then it crashes here:
TypeError: Serialization error for configuration.toServer : Write error for undefined : Cannot read properties of undefined (reading '0')
at Function.parse (***\node_modules\uuid-1345\index.js:137:36)
at module.exports.Write.UUID (***\node_modules\minecraft-protocol\src\datatypes\compiler-minecraft.js:48:76)
What did you try yet?
I edited compiler-minecraft and changed this:
UUID: ['native', (value, buffer, offset) => {
const buf = value.length === 32 ? Buffer.from(value, 'hex') : UUID.parse(value)
buf.copy(buffer, offset)
return offset + 16
}],
into this:
UUID: ['native', (value, buffer, offset) => {
if (value) {
const buf = value.length === 32 ? Buffer.from(value, 'hex') : UUID.parse(value)
buf.copy(buffer, offset)
}
return offset + 16
}],
And it resolved my issue. Additionally, I was able to reproduce the bug on a localhost server using no other plugins or configs other than setting a server resource pack.
Your current code
import { readFileSync } from 'node:fs';
import { createBot } from 'mineflayer';
const config = JSON.parse(readFileSync('config.json'));
const { host, port, password } = config;
const bot = createBot({
host,
port,
username: 'nycki_afk',
auth: 'offline',
});
bot.on('spawn', () => {
bot.chat(`/login ${password}`)
});
bot.on('resourcePack', (url) => {
bot.denyResourcePack();
});
bot.on('error', console.log)
bot.on('kicked', console.log)