aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder/mod.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-03 09:52:30 +0930
committermat <git@matdoes.dev>2025-06-03 09:52:30 +0930
commitf3a5e91a8ccbcd03a239aa3565dbfddabb26fa76 (patch)
treeb9f34dda5ba68bbfc4159dd1631455c8dd84e2ad /azalea/src/pathfinder/mod.rs
parent7517a207db658c98d5b97b3b3f44df6725c025a2 (diff)
downloadazalea-drasl-f3a5e91a8ccbcd03a239aa3565dbfddabb26fa76.tar.xz
fix issues when pathfinding to non-full blocks and add Client::view_inventory
Diffstat (limited to 'azalea/src/pathfinder/mod.rs')
-rw-r--r--azalea/src/pathfinder/mod.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 5ee56643..b05d2aab 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -274,10 +274,8 @@ impl PathfinderClientExt for azalea_client::Client {
}
fn is_goto_target_reached(&self) -> bool {
- self.map_get_component::<Pathfinder, _>(|p| {
- p.map(|p| p.goal.is_none() && !p.is_calculating)
- .unwrap_or(true)
- })
+ self.map_get_component::<Pathfinder, _>(|p| p.goal.is_none() && !p.is_calculating)
+ .unwrap_or(true)
}
}
@@ -689,7 +687,12 @@ pub fn timeout_movement(
let world_lock = instance_container
.get(instance_name)
.expect("Entity tried to pathfind but the entity isn't in a valid world");
- let successors_fn: moves::SuccessorsFn = pathfinder.successors_fn.unwrap();
+ let Some(successors_fn) = pathfinder.successors_fn else {
+ warn!(
+ "pathfinder was going to patch path because of timeout, but there was no successors_fn"
+ );
+ return;
+ };
let custom_state = custom_state.cloned().unwrap_or_default();
@@ -749,7 +752,8 @@ pub fn check_node_reached(
let z_difference_from_center = position.z - (movement.target.z as f64 + 0.5);
// this is to make sure we don't fall off immediately after finishing the path
physics.on_ground()
- && BlockPos::from(position) == movement.target
+ // 0.5 to handle non-full blocks
+ && BlockPos::from(position.up(0.5)) == movement.target
// adding the delta like this isn't a perfect solution but it helps to make
// sure we don't keep going if our delta is high
&& (x_difference_from_center + physics.velocity.x).abs() < 0.2