无法访问对象内的 mineflayer 探路者

Cant access mineflayer pathfinder inside an object

这里是nodejs中的全部代码

const mineflayer = require('mineflayer')
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder');
const GoalFollow = goals.GoalFollow


function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

class bot{
  constructor(name, ip, port){
    this.name = name;
    this.ip = ip;
    this.port = port


    this.minebot = mineflayer.createBot({
      host: this.ip,
      username: this.name,
      port: this.port
    })

    this.minebot.on('spawn', () => {
      for(let i = 0; i < 1; i++){
        this.minebot.chat(this.name);
        this.followPlayer('Squisheyyy')
      }
    })

    this.minebot.on('kicked', () => {
      console.log('Connection closed, retrying');
      new bot(this.name, this.ip, this.port);
      delete this;
    });

    this.minebot.on('error', () => {
      console.log('Connection closed, retrying');
      new bot(this.name, this.ip, this.port);
      delete this;
    });

  }

  followPlayer(name){
    const playerCI = this.minebot.players[name];

    if(!playerCI){
      bot.chat('I dont see him');
      return;
    }

    const mcData = require('minecraft-data')(this.minebot.version);
    const movements = new Movements(this.minebot, mcData);
    this.minebot.pathfinder.setMovements(movements);

    const goal = new GoalFollow(playerCI.entity, 1);
    this.minebot.pathfinder.setGoal(goal, true);
  }
}

new bot('bot', 'ip', PORT)

这是有这个问题的行 this.minebot.pathfinder.setMovements(movements); 错误: TypeError: Cannot read properties of undefined (reading 'setMovements')

它说 pathfinder 未定义,IDE 也告诉我 'pathfinder' 在代码顶部声明,但它的值从未被读取,我看过一些视频,这应该有效, 但它就是没有,可能是因为我在一个物体里面。

我目前使用的是最新版本的 mineflayer

pathfinder是一个mineflayer插件,这意味着它必须被加载。 我忘了写

this.mineflayer.loadPlugin(pathfinder)