Closed SinanAkkoyun closed 3 years ago
My code:
bot.on("playerJoined", (player) => {
if(goal_memory && goal_memory[0] instanceof goals.GoalFollow && goal_memory[0].entity.username.trim() === player.username.trim()) {
setTimeout(() => { //Non blocking while would be better
if(bot.players[player.username] && bot.players[player.username].entity) {
bot.pathfinder.setGoal(bot.players[player.username].entity, goal_memory[1])
log("[Pathfinder] Set goal to last memory.")
} else {
log("[Memory] Error, could not get entity of " + player.username + ".")
}
}, 3000);
}
})
btw the bot loses track after a disconnect or world change of the target, likely the entity gets set new then or something
do you know any better way to keep the goal in the bots "memory"?
And why is there no function to get the current goal of the pathfinder? Would be so useful
You need to read the documentation: https://github.com/PrismarineJS/mineflayer-pathfinder#botpathfindersetgoalgoal-dynamic
setGoal
expect a goal instance and a boolean, you are giving it an entity and a goal instance. Parameters order and type are not optional, you need to follow the doc and example.
You can get the current goal with bot.pathfinder.goal
Oh man I am so dumb XD Thank you!!!!
Hi, why is this happening?