aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-12-24 05:18:33 +0000
committermat <git@matdoes.dev>2024-12-24 05:18:33 +0000
commitde5a53ce08de5b9d77bce99dd9ecde3171ebd74e (patch)
tree02c84b356f8dc20ea882793001dd229adfa02121
parent958848e8ed10c7b8a83c9faea1fac6eaac39b018 (diff)
downloadazalea-drasl-de5a53ce08de5b9d77bce99dd9ecde3171ebd74e.tar.xz
add additional pathfinder test and fix pathfinder failure
-rwxr-xr-xazalea-core/src/position.rs1
-rw-r--r--azalea/src/pathfinder/mod.rs21
-rw-r--r--azalea/src/pathfinder/moves/parkour.rs5
3 files changed, 26 insertions, 1 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index 14ecfcc1..be06e825 100755
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -212,6 +212,7 @@ macro_rules! vec3_impl {
}
/// Used to represent an exact position in the world where an entity could be.
+///
/// For blocks, [`BlockPos`] is used instead.
#[derive(Clone, Copy, Debug, Default, PartialEq, AzBuf)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 802d9ebd..b82b5f84 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -945,6 +945,7 @@ mod tests {
// simulation.app.add_plugins(bevy_log::LogPlugin {
// level: bevy_log::Level::TRACE,
// filter: "".to_string(),
+ // ..Default::default()
// });
simulation.app.world_mut().send_event(GotoEvent {
@@ -1153,4 +1154,24 @@ mod tests {
);
assert_simulation_reaches(&mut simulation, 80, BlockPos::new(4, 71, 12));
}
+
+ #[test]
+ fn test_jumps_with_more_sideways_momentum() {
+ let mut partial_chunks = PartialChunkStorage::default();
+ let mut simulation = setup_blockposgoal_simulation(
+ &mut partial_chunks,
+ BlockPos::new(0, 71, 0),
+ BlockPos::new(2, 74, 9),
+ vec![
+ BlockPos::new(0, 70, 0),
+ BlockPos::new(0, 70, 1),
+ BlockPos::new(0, 70, 2),
+ BlockPos::new(0, 71, 3),
+ BlockPos::new(0, 72, 6),
+ BlockPos::new(0, 73, 9),
+ BlockPos::new(2, 73, 9),
+ ],
+ );
+ assert_simulation_reaches(&mut simulation, 80, BlockPos::new(2, 74, 9));
+ }
}
diff --git a/azalea/src/pathfinder/moves/parkour.rs b/azalea/src/pathfinder/moves/parkour.rs
index 0f279dca..1d35f323 100644
--- a/azalea/src/pathfinder/moves/parkour.rs
+++ b/azalea/src/pathfinder/moves/parkour.rs
@@ -1,5 +1,6 @@
use azalea_client::{SprintDirection, WalkDirection};
use azalea_core::{direction::CardinalDirection, position::BlockPos};
+use tracing::trace;
use super::{Edge, ExecuteCtx, IsReachedCtx, MoveData, PathfinderCtx};
use crate::pathfinder::{astar, costs::*};
@@ -212,12 +213,14 @@ fn execute_parkour_move(mut ctx: ExecuteCtx) {
if !is_at_start_block
&& !is_at_jump_block
&& (position.y - start.y as f64) < 0.094
- && distance_from_start < 0.81
+ && distance_from_start < 0.85
{
// we have to be on the start block to jump
ctx.look_at(start_center);
+ trace!("looking at start_center");
} else {
ctx.look_at(target_center);
+ trace!("looking at target_center");
}
if !is_at_start_block && is_at_jump_block && distance_from_start > required_distance_from_center