My bot was working perfectly fine, but then I updated to latest version of mineflayer-pathfinder and now it crashes every time I make it pathfind.
This is log:
Connected
Following FedexxedeF
Vec3 { x: 1.8191804113916277, y: 71, z: -489.47380431184274 }
C:\Users\Toshiba\node_modules\mineflayer-pathfinder\index.js:62
const start = new Move(p.x, p.y + (b && dy > 0.001 && bot.entity.onGround && b.type !== 0 ? 1 : 0), p.z, movements.countScaffoldingItems(), 0)
^
TypeError: movements.countScaffoldingItems is not a function
at Object.bot.pathfinder.getPathTo (C:\Users\Toshiba\node_modules\mineflayer-pathfinder\index.js:62:120)
at EventEmitter.monitorMovement (C:\Users\Toshiba\node_modules\mineflayer-pathfinder\index.js:341:42)
at EventEmitter.emit (events.js:327:22)
at Timeout.doPhysics [as _onTimeout] (C:\Users\Toshiba\node_modules\mineflayer\lib\plugins\physics.js:65:13)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
And this is my code:
const mineflayer = require('mineflayer');
const owner = process.argv[3] || "FedexxedeF"
const pass = process.argv[4];
const pvp = require('./mineflayer-pvp').plugin
const armor_manager = require("./mineflayer-armor-manager")
var isAttackingMobs = "false"
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = class Movements {
constructor (bot, mcData) {
this.bot = bot
this.canDig = false
this.digCost = 10
}}
const { GoalNear, GoalBlock, GoalXZ, GoalY, GoalInvert, GoalFollow } = require('mineflayer-pathfinder').goals
const options = {
host: process.argv[2],
port: 25565,
username: "Xbot",
password: process.argv[4],
}
const bot = mineflayer.createBot(options)
bot.once('spawn', () => {
bot.loadPlugin(pathfinder)
bot.loadPlugin(pvp)
// Once we've spawn, it is safe to access mcData because we know the version
const mcData = require('minecraft-data')(bot.version)
const movements = new Movements(bot, mcData)
movements.canDig = false
bot.pathfinder.setMovements(movements)
bot.settings.viewDistance = "tiny"
bot.chat('/login ' + pass)
bot.chat('Xbot by Fede!')
console.log("Connected")
// We create different movement generators for different type of activity
const defaultMove = new Movements(bot, mcData)
//every 1 second go forward
/*
setInterval(function(){
bot.setControlState("back", false)
bot.setControlState("forward", true)
},1000)
setInterval(function(){
bot.setControlState("forward", false)
bot.setControlState("back", true)
},1100)
*/
});
setInterval(() =>{
if (isAttackingMobs === "false") return
const mobFilter = e => e.type === "mob"
const mob = bot.nearestEntity(mobFilter)
if (!mob) return
if (mob && mob.kind.toString().toLowerCase().includes('hostile')) {
bot.pvp.attack(mob)
}
},1000);
bot.on( "kicked", (reason, loggedIn) => {
console.log("KICKED! "+ reason)
})
bot.on("chat", function(username, message) {
const target = bot.players[username] ? bot.players[username].entity : null
var pmessage = message.split(' ')
if (message.split('_')[0] != "") { return }
if (username === bot.username) return
if (username != owner) {
console.log("Player " + username + " had not enough permissions to execute command!")
bot.whisper(username, "You got not enough permissions to execute this command!")
return
}
if (message === "_come") {
bot.chat('/teleport ' + bot.username + " " + username );
bot.whisper(username, 'Teleported to ' + username);
console.log("Teleported to " + username + "'s position");
};
if (message === "_follow") {
if (!target) {
bot.chat("I don't see you !")
return
}
bot.whisper(username, 'Following you!');
console.log("Following " + username );
bot.pathfinder.setGoal(new GoalFollow(target, 3), true)
console.log(bot.players[username].entity.position)
isAttackingMobs = "false"
};
if (message === "_stop") {
isAttackingMobs = "false";
console.log("stopping")
bot.chat("Stopping.")
}
if (pmessage[0] === "_attack") {
if (pmessage[1] === "hostiles") {
isAttackingMobs = "true"
console.log("Attacking Hostiles!")
bot.chat("Attacking hostiles!")
}
else {
const player = bot.players[pmessage[1]]
if (!player) {
bot.chat("I can't see "+ player)
return
}
if (pmessage[1]) {
bot.pvp.attack(player.entity)
}
}
};
/*
if (message === '_fight') {
const player = bot.players[username]
if (!player) {
bot.chat("I can't see you.")
return
}
bot.chat('Prepare to fight!')
bot.pvp.attack(player.entity)
}*/
});
My bot was working perfectly fine, but then I updated to latest version of mineflayer-pathfinder and now it crashes every time I make it pathfind. This is log:
And this is my code:
Thank you for the help.