diff options
| author | mat <git@matdoes.dev> | 2026-01-06 04:26:29 +0200 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-05 17:57:54 -0900 |
| commit | 9c2c7c3497a74e80d7186fdcd97ce2518520faa6 (patch) | |
| tree | 3c4984e3a42ecaf4dcc5fa7503d83c734a03477e /azalea/src/pathfinder/mod.rs | |
| parent | 28fe2d21dc03b96baa61c3b142baff3af5b92a76 (diff) | |
| download | azalea-drasl-9c2c7c3497a74e80d7186fdcd97ce2518520faa6.tar.xz | |
pathfinder fixes and api improvements
don't pathfind on magma, fix mining blocks while swimming, fix RadiusGoal heuristic, and add Client::physics, is_executing_path, and is_calculating_path
Diffstat (limited to 'azalea/src/pathfinder/mod.rs')
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 905a90fe..fe94e42d 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -227,6 +227,16 @@ pub trait PathfinderClientExt { /// Returns true if the pathfinder has no active goal and isn't calculating /// a path. fn is_goto_target_reached(&self) -> bool; + /// Whether the pathfinder is currently following a path. + /// + /// Also see [`Self::is_calculating_path`] and + /// [`Self::is_goto_target_reached`]. + fn is_executing_path(&self) -> bool; + /// Whether the pathfinder is currently calculating a path. + /// + /// Also see [`Self::is_executing_path`] and + /// [`Self::is_goto_target_reached`]. + fn is_calculating_path(&self) -> bool; } impl PathfinderClientExt for Client { @@ -257,6 +267,7 @@ impl PathfinderClientExt for Client { force: true, }); } + async fn wait_until_goto_target_reached(&self) { // we do this to make sure the event got handled before we start checking // is_goto_target_reached @@ -273,10 +284,15 @@ impl PathfinderClientExt for Client { } } fn is_goto_target_reached(&self) -> bool { - self.query_self::<Option<&Pathfinder>, _>(|p| { - p.map(|p| p.goal.is_none() && !p.is_calculating) - .unwrap_or(true) - }) + self.get_component::<Pathfinder>() + .is_none_or(|p| p.goal.is_none() && !p.is_calculating) + } + fn is_executing_path(&self) -> bool { + self.get_component::<ExecutingPath>().is_some() + } + fn is_calculating_path(&self) -> bool { + self.get_component::<Pathfinder>() + .is_some_and(|p| p.is_calculating) } } |
