Skip to content

Commit

Permalink
add additional pathfinder test and fix pathfinder failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Dec 24, 2024
1 parent 958848e commit de5a53c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions azalea-core/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
21 changes: 21 additions & 0 deletions azalea/src/pathfinder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
}
}
5 changes: 4 additions & 1 deletion azalea/src/pathfinder/moves/parkour.rs
Original file line number Diff line number Diff line change
@@ -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::*};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de5a53c

Please sign in to comment.