Skip to content
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

Having any goal outside renderdistance crashes the bot with NoPath #229

Open
Lawerencium opened this issue Dec 17, 2021 · 2 comments
Open

Comments

@Lawerencium
Copy link

Lawerencium commented Dec 17, 2021

I know, i should make a catch for NoPath, but cant seem to figure out why it cant find paths outside of its renderdistance. It stops the bot after aboutt 4 blocks of walking and sometimes even before it started.

  const err = new Error(message)
              ^

NoPath: No path to the goal!
    at error (/home/pi/Desktop/BBs/node_modules/mineflayer-pathfinder/lib/goto.js:2:15)
    at EventEmitter.noPathListener (/home/pi/Desktop/BB/node_modules/mineflayer-pathfinder/lib/goto.js:26:17)
    at EventEmitter.emit (node:events:379:20)
    at EventEmitter.monitorMovement (/home/pi/Desktop/BB/node_modules/mineflayer-pathfinder/index.js:341:11)
    at EventEmitter.emit (node:events:391:22)
    at Timeout.doPhysics [as _onTimeout] (/home/pi/Desktop/BB/node_modules/mineflayer/lib/plugins/physics.js:65:13)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499:7)

i'm not sure where this is going wrong. I'm using the code below which in my monkey brain should work just fine?

await bot.waitForChunksToLoad()
client.channels.cache.get(message.channel.id).send('chunks have been loaded');
 
var goal = new GoalBlock(Coords in x,y,z format (0,0,0))

if (message.author.id == "INSERT DISCORD-ID HERE") {
  goal = new GoalBlock(Coords in x,y,z format ("INSERT X,Y,Z COORDS HERE"))
} else {return client.channels.cache.get(message.channel.id).send('you cant use this command');}

bot.pathfinder.setMovements(defaultMove)

client.channels.cache.get(message.channel.id).send('bot is walking to the destination');
await bot.pathfinder.goto(goal)

Please help, what am i doing wrong that my lovely bot hates me xD

@IceTank
Copy link
Collaborator

IceTank commented Apr 3, 2022

I don't think there is a check if pathfinder has reached the edge off unloaded chunks when planing paths. You can try and set a goal like GoalNearXZ that is not specific to one block.

@IceTank
Copy link
Collaborator

IceTank commented Jul 2, 2022

There is also another issue with goto. goto treats noPath as a failure case. But the bot can still path the partial calculated path even when the calculations returned noPath. If you use setGoal instead of goto the bot will path to the loaded chunk edge and recalculate the path when new chunks load.

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

No branches or pull requests

2 participants