PrismarineJS / mineflayer-navigate

mineflayer plugin which gives bots a high level 3d navigating API using A*
59 stars 22 forks source link

Placing blocks messes up path #48

Closed UltimateGG closed 4 years ago

UltimateGG commented 4 years ago

Hello, Basically I have a bot which is just moving back and forth between 2 points, and while doing that it just places sand block off of the block its looking at. When I turn on the block placing, it seems to think it has arrived (after moving like 5 blocks) at the far point and tries to move to the first point again.

It almost looks like placing a block slows it down or something I can't seem to find why this happens. I changed the path to just be in 2 directions so the head doesn't move its just using control state left and right.

I have no clue what code to post since I have it all over the place, so Ill show a gif of what happens. The yellow cords are the x of the block its looking at. The spam gray is showing which way its trying to set the control state/direction of movement to.

https://gyazo.com/6fbefb719a5797be7574b4662dc75948

Keep in mind it only freezes the path when I have it placing blocks.

I just want to know if theres a simple fix for this, because if not Its a bit more work but I can just make it go back and forth and detect when it hits the point with no path ai.

rom1504 commented 4 years ago

Yes placing blocks will cause issue as it doesn't redo the path finding every step, it does it once then apply it. I would advise trying to detect when it's blocked and redoing navigate at that point so it computes a new path. A simple heuristic might be to do navigate in an async loop until the bot got to its destination (check with bot.position)

UltimateGG commented 4 years ago

Yea I just made it check cords every like 40 ms and set state based on the other point