aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder/goals.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/src/pathfinder/goals.rs')
-rw-r--r--azalea/src/pathfinder/goals.rs8
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;
}