aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-10-06 16:08:19 -0500
committermat <git@matdoes.dev>2023-10-06 16:08:26 -0500
commit94ef48d9f2e362167c077b9584e42ed2c71d679f (patch)
tree1670cbdc946ce9574f20f6ed6a49e061394bf602 /azalea
parent30702d94f65a2bd86c9ac0a7c402675b89ac4364 (diff)
downloadazalea-drasl-94ef48d9f2e362167c077b9584e42ed2c71d679f.tar.xz
make sure pathfinder is always centered on the destination block (fixes tests)
Diffstat (limited to 'azalea')
-rw-r--r--azalea/src/pathfinder/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index c4c4c688..5d417e91 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -381,7 +381,13 @@ fn tick_execute_path(
physics,
};
let extra_strict_if_last = if i == pathfinder.path.len() - 1 {
- physics.on_ground && BlockPos::from(position) == movement.target
+ let x_difference_from_center = position.x - (movement.target.x as f64 + 0.5);
+ 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
+ && x_difference_from_center.abs() < 0.2
+ && z_difference_from_center.abs() < 0.2
} else {
true
};