diff options
| author | mat <git@matdoes.dev> | 2025-06-03 09:52:30 +0930 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-03 09:52:30 +0930 |
| commit | f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76 (patch) | |
| tree | b9f34dda5ba68bbfc4159dd1631455c8dd84e2ad /azalea/src/pathfinder/goals.rs | |
| parent | 7517a207db658c98d5b97b3b3f44df6725c025a2 (diff) | |
| download | azalea-drasl-f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76.tar.xz | |
fix issues when pathfinding to non-full blocks and add Client::view_inventory
Diffstat (limited to 'azalea/src/pathfinder/goals.rs')
| -rw-r--r-- | azalea/src/pathfinder/goals.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs index 5ab969c9..36fca762 100644 --- a/azalea/src/pathfinder/goals.rs +++ b/azalea/src/pathfinder/goals.rs @@ -29,7 +29,9 @@ impl Goal for BlockPosGoal { xz_heuristic(dx, dz) + y_heuristic(dy) } fn success(&self, n: BlockPos) -> bool { - n == self.0 + // the second half of this condition is intended to fix issues when pathing to + // non-full blocks + n == self.0 || n.down(1) == self.0 } } @@ -219,8 +221,8 @@ impl Goal for ReachBlockPosGoal { } fn success(&self, n: BlockPos) -> bool { // only do the expensive check if we're close enough - let distance = (self.pos - n).length_squared(); - if distance > self.max_check_distance * self.max_check_distance { + let distance = self.pos.distance_squared_to(&n); + if distance > self.max_check_distance.pow(2) { return false; } |
