Skip to content

bot wont connect to the server properly in any version obove 1.20.1 #3607

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

Open
Thomasnbawa opened this issue Mar 13, 2025 · 14 comments
Open

Comments

@Thomasnbawa
Copy link

  • [√] The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.26.0
  • server: paper 1.21.4
  • node: 22.14.0

Detailed description of a problem

bot wont connect to the server properly
it just printed "bot create success **(see my code)" in the console
the server has this log: UUID of player BotAccT is b33b9df3-a39b-31f9-8fe2-f10c1f01c4fb

What did you try yet?

i even hadnt got an error about it in my console while running the programs/examples.the bot just woudnt connect.

Your current code

const mineflayerViewer = require('prismarine-viewer').mineflayer
const mineflayer = require('mineflayer');
const readline = require('readline');
// 创建机器人
const bot = mineflayer.createBot({
  host: 'p**********n', // Minecraft 服务器地址
  port: 1***6,        // Minecraft 服务器端口
  version: '1.21.4',
  username: 'BotAccT',     // 机器人的用户名
  auth: 'offline',
  hideErrors: 'false'
});
console.log('bot create success');
// 设置控制台输入
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

// 监听控制台输入
rl.on('line', (input) => {
  const command = input.trim().toLowerCase();

  switch (command) {
    case 'w':
      bot.setControlState('forward', true);
      break;
    case 's':
      bot.setControlState('back', true);
      break;
    case 'a':
      bot.setControlState('left', true);
      break;
    case 'd':
      bot.setControlState('right', true);
      break;
    case 'stop':
      bot.clearControlStates();
      break;
    case 'j':
      bot.setControlState('jump', true);
      setTimeout(() => bot.setControlState('jump', false), 500);
      break;
    default:
      if (command.startsWith('/')) {
        // 如果是指令(以 / 开头)
        bot.chat(command); // 发送指令
      } else if (command) {
        // 如果是普通聊天消息
        bot.chat(command); // 发送聊天消息
      } else {
        console.log('未知命令');
      }
  }
});

// 机器人连接成功时触发
bot.once('spawn', () => {
  console.log('机器人已连接,可以通过以下命令控制:');
  console.log('w: 前进');
  console.log('s: 后退');
  console.log('a: 左移');
  console.log('d: 右移');
  console.log('jump: 跳跃');
  console.log('stop: 停止移动');
  console.log('/<command>: 执行指令(例如 /help)');
  console.log('<message>: 发送聊天消息');
  mineflayerViewer(bot, { port: 3007, firstPerson: false })
});

// 机器人断开连接时触发
bot.on('end', () => {
  console.log('机器人已断开连接');
  rl.close();
});

// 机器人错误处理
bot.on('error', (err) => {
  console.error('机器人发生错误:', err);
});

Expected behavior

the bot could connect to the server properly, using version 1.21.4.

Additional context

please.....anyone who could help?

@Thomasnbawa Thomasnbawa 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 Mar 13, 2025
@Thomasnbawa Thomasnbawa changed the title bot wont connect to the server properly in 1.21.1 1.21.4 bot wont connect to the server properly in any version obove 1.20.1 Mar 13, 2025
@1tsMeMario
Copy link
Contributor

bot create success
机器人已连接,可以通过以下命令控制:
w: 前进
s: 后退
a: 左移
d: 右移
jump: 跳跃
stop: 停止移动
/: 执行指令(例如 /help)
: 发送聊天消息
Prismarine viewer web server running on *:3007

connected fine to my paper 1.21.4 server so its likely your server causing issues

@1tsMeMario
Copy link
Contributor

ive been using mineflayer on 1.21.x servers for a bit now

@extremeheat extremeheat added waiting info from op and removed possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Mar 30, 2025
@extremeheat
Copy link
Member

See if you can reproduce on a different server. Otherwise, it could be a server specific problem that can't be fixed without you debugging it

@PseudoResonance
Copy link

See if you can reproduce on a different server. Otherwise, it could be a server specific problem that can't be fixed without you debugging it

I don't know what server this person is playing on, but given their server host says p**********n, and the comments are in Chinese, it appears the server IP may be play.***.cn. Given that Hypixel China shut down a few years ago, I'm fairly certain the server @Thomasnbawa is attempting to connect to is not Hypixel.

All that to say, there's at least 2 independent servers that exhibit this same behavior. This one, and Hypixel.

@Sebastien-Moraz
Copy link

play.wynncraft.com has a same problem with 1.20.5+.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

What is "same problem" ? This issue has 0 information yet, so how can you identify it's the same problem?

Please follow the debug info in the readme to provide info so it's possible to debug.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

If you want to make sure that non vanilla server get better support in general then contribute to #1200

@PseudoResonance
Copy link

What is "same problem" ? This issue has 0 information yet, so how can you identify it's the same problem?

Please follow the debug info in the readme to provide info so it's possible to debug.

Sorry, I forgot to comment here, but this is likely a duplicate of #3623.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

#3623 also has no information so yes it's a duplicate in the sense "cannot reproduce or fix"

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Ah you did put the debug info there I see

@PseudoResonance
Copy link

#3623 also has no information so yes it's a duplicate in the sense "cannot reproduce or fix"

Hardly... It has a full repo for minimal reproduction, debug logs, analysis of the cause and a likely error...

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Yeah so definitely not a duplicate

@PseudoResonance
Copy link

Yeah so definitely not a duplicate

Well, my issue was documented a whole lot better than this one, but I'm pretty sure the root cause at least is the same. Although, I guess we will never know if @Thomasnbawa never provides anything... Oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants