mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 23:44:38 +00:00
add Client::force_stop_pathfinding
This commit is contained in:
parent
302752860c
commit
9719d00526
1 changed files with 17 additions and 0 deletions
|
@ -167,6 +167,7 @@ pub trait PathfinderClientExt {
|
||||||
fn start_goto(&self, goal: impl Goal + 'static);
|
fn start_goto(&self, goal: impl Goal + 'static);
|
||||||
fn start_goto_without_mining(&self, goal: impl Goal + 'static);
|
fn start_goto_without_mining(&self, goal: impl Goal + 'static);
|
||||||
fn stop_pathfinding(&self);
|
fn stop_pathfinding(&self);
|
||||||
|
fn force_stop_pathfinding(&self);
|
||||||
fn wait_until_goto_target_reached(&self) -> impl Future<Output = ()>;
|
fn wait_until_goto_target_reached(&self) -> impl Future<Output = ()>;
|
||||||
fn is_goto_target_reached(&self) -> bool;
|
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));
|
.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) {
|
fn stop_pathfinding(&self) {
|
||||||
self.ecs.lock().send_event(StopPathfindingEvent {
|
self.ecs.lock().send_event(StopPathfindingEvent {
|
||||||
entity: self.entity,
|
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.
|
/// Waits forever until the bot no longer has a pathfinder goal.
|
||||||
async fn wait_until_goto_target_reached(&self) {
|
async fn wait_until_goto_target_reached(&self) {
|
||||||
// we do this to make sure the event got handled before we start checking
|
// we do this to make sure the event got handled before we start checking
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue