Minecraft ERRCONNECT MINEFLAYER ERROR 错误:连接 ECONNREFUSED ::1:25595

问题描述 投票:0回答:1

当我运行这个简单的代码片段时,我收到了这个错误

import mineflayer from 'mineflayer';

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25595,
  username: 'Maaz_Bot', // minecraft username
  password:''
})

我期待它通过使用 lan world 和 mineflayer 库加入托管在端口 25595 的本地主机服务器

javascript node.js error-handling minecraft mineflayer
1个回答
0
投票

尝试像下面这样导入 mineflayer,您也可以处理使用、登录和错误时的事件

const mineflayer = require('mineflayer');

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25595,
  username: 'Maaz_Bot', // minecraft username
  password: '',
});

bot.on('login', () => {
  console.log('Bot has logged in');
});

bot.on('error', (err) => {
  console.error('Error:', err);
});

有关更多信息,请阅读文档

https://www.npmjs.com/package/mineflayer

© www.soinside.com 2019 - 2024. All rights reserved.