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

can't connect to offline server with resource pack #3407

Open
1 task done
nycki93 opened this issue Jun 26, 2024 · 0 comments
Open
1 task done

can't connect to offline server with resource pack #3407

nycki93 opened this issue Jun 26, 2024 · 0 comments
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

@nycki93
Copy link

nycki93 commented Jun 26, 2024

  • 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)
@nycki93 nycki93 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 Jun 26, 2024
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

1 participant