diff options
| author | mat <git@matdoes.dev> | 2026-03-06 11:12:07 +0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-06 11:12:07 +0500 |
| commit | 8dc511bb1b77da67d5428e8bafeab92ad3bfabf4 (patch) | |
| tree | b155417c3470412bc9dcf2f39f8440f71c805335 /azalea/src/pathfinder/execute | |
| parent | 62eb3ec38cca04ac09156bb2693a9f8ca82b3da6 (diff) | |
| download | azalea-drasl-8dc511bb1b77da67d5428e8bafeab92ad3bfabf4.tar.xz | |
fix various regressions from optimization attempts
Diffstat (limited to 'azalea/src/pathfinder/execute')
| -rw-r--r-- | azalea/src/pathfinder/execute/mod.rs | 5 | ||||
| -rw-r--r-- | azalea/src/pathfinder/execute/simulation.rs | 53 |
2 files changed, 33 insertions, 25 deletions
diff --git a/azalea/src/pathfinder/execute/mod.rs b/azalea/src/pathfinder/execute/mod.rs index d022885c..f4214054 100644 --- a/azalea/src/pathfinder/execute/mod.rs +++ b/azalea/src/pathfinder/execute/mod.rs @@ -26,7 +26,7 @@ use crate::{ system::{Commands, Query, Res}, }, pathfinder::{ - ExecutingPath, GotoEvent, Pathfinder, + ExecutingPath, GotoEvent, Pathfinder, PathfinderSystems, astar::PathfinderTimeout, custom_state::CustomPathfinderState, debug::debug_render_path_with_particles, @@ -60,7 +60,8 @@ impl Plugin for DefaultPathfinderExecutionPlugin { .after(PhysicsSystems) .after(azalea_client::movement::send_position) .after(MiningSystems) - .after(debug_render_path_with_particles), + .after(debug_render_path_with_particles) + .in_set(PathfinderSystems), ); } } diff --git a/azalea/src/pathfinder/execute/simulation.rs b/azalea/src/pathfinder/execute/simulation.rs index a002df4d..7287587b 100644 --- a/azalea/src/pathfinder/execute/simulation.rs +++ b/azalea/src/pathfinder/execute/simulation.rs @@ -25,7 +25,7 @@ use crate::{ system::{Commands, Query}, }, pathfinder::{ - ExecutingPath, + ExecutingPath, PathfinderSystems, debug::debug_render_path_with_particles, moves::{ExecuteCtx, IsReachedCtx}, simulation::{SimulatedPlayerBundle, Simulation}, @@ -68,7 +68,8 @@ impl Plugin for SimulationPathfinderExecutionPlugin { .after(PhysicsSystems) .after(azalea_client::movement::send_position) .after(MiningSystems) - .after(debug_render_path_with_particles), + .after(debug_render_path_with_particles) + .in_set(PathfinderSystems), ); } } @@ -213,6 +214,7 @@ pub fn tick_execute_path( direction: SprintDirection::Forward, }); } else if physics_state.was_sprinting { + // have to let go for a tick to be able to start walking walk_events.write(StartWalkEvent { entity, direction: WalkDirection::None, @@ -342,6 +344,10 @@ fn run_one_simulation( let start = BlockPos::from(player.position); sim.reset(player); + // run an Update to initialize some things, including at least the Bot component + // (which is needed for jumping) + sim.run_update_schedule(); + let simulating_to_block = simulating_to.movement.target; let mut success = false; @@ -349,6 +355,27 @@ fn run_one_simulation( for ticks in 1..=timeout_ticks { let position = sim.position(); + let physics = sim.physics(); + + if physics.horizontal_collision + || physics.is_in_lava() + || (physics.velocity.y < -0.7 && !physics.is_in_water()) + { + // fail + break; + } + + if (simulating_to.movement.data.is_reached)(IsReachedCtx { + target: simulating_to_block, + start, + position, + physics: &physics, + }) { + success = true; + total_ticks = ticks; + break; + } + let ecs = sim.app.world_mut(); ecs.get_mut::<LookDirection>(sim.entity) @@ -362,7 +389,7 @@ fn run_one_simulation( }); } else if ecs .get::<PhysicsState>(sim.entity) - .map(|p| p.trying_to_sprint) + .map(|p| p.was_sprinting) .unwrap_or_default() { // have to let go for a tick to be able to start walking @@ -388,26 +415,6 @@ fn run_one_simulation( } sim.tick(); - - let physics = sim.physics(); - if physics.horizontal_collision - || physics.is_in_lava() - || (physics.velocity.y < -0.7 && !physics.is_in_water()) - { - // fail - break; - } - - if (simulating_to.movement.data.is_reached)(IsReachedCtx { - target: simulating_to_block, - start, - position: sim.position(), - physics: &physics, - }) { - success = true; - total_ticks = ticks; - break; - } } if success { |
