diff options
| author | mat <git@matdoes.dev> | 2025-07-24 21:26:49 +1100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-07-24 21:26:49 +1100 |
| commit | 9719d00526880ec9e41d7ae622fb74354ad18c98 (patch) | |
| tree | e491c01fbb61fc9972bcb45c7c27e64b888aa874 | |
| parent | 302752860c7c10f02479727fe3d6d3b086177604 (diff) | |
| download | azalea-drasl-9719d00526880ec9e41d7ae622fb74354ad18c98.tar.xz | |
add Client::force_stop_pathfinding
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 9786e1de..f07b3470 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -167,6 +167,7 @@ pub trait PathfinderClientExt { fn start_goto(&self, goal: impl Goal + 'static); fn start_goto_without_mining(&self, goal: impl Goal + 'static); fn stop_pathfinding(&self); + fn force_stop_pathfinding(&self); fn wait_until_goto_target_reached(&self) -> impl Future<Output = ()>; fn is_goto_target_reached(&self) -> bool; } @@ -212,6 +213,13 @@ impl PathfinderClientExt for azalea_client::Client { .send_event(GotoEvent::new(self.entity, goal).with_allow_mining(false)); } + /// Stop calculating a path, and stop moving once the current movement is + /// finished. + /// + /// This behavior exists to prevent the bot from taking damage if + /// `stop_pathfinding` was called while executing a parkour jump, but if + /// it's undesirable then you may want to consider using + /// [`Self::force_stop_pathfinding`] instead. fn stop_pathfinding(&self) { self.ecs.lock().send_event(StopPathfindingEvent { entity: self.entity, @@ -219,6 +227,15 @@ impl PathfinderClientExt for azalea_client::Client { }); } + /// Stop calculating a path and stop executing the current movement + /// immediately. + fn force_stop_pathfinding(&self) { + self.ecs.lock().send_event(StopPathfindingEvent { + entity: self.entity, + force: true, + }); + } + /// Waits forever until the bot no longer has a pathfinder goal. async fn wait_until_goto_target_reached(&self) { // we do this to make sure the event got handled before we start checking |
