From f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 3 Jun 2025 09:52:30 +0930 Subject: fix issues when pathfinding to non-full blocks and add Client::view_inventory --- azalea/src/pathfinder/goals.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'azalea/src/pathfinder/goals.rs') 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; } -- cgit v1.2.3