diff options
Diffstat (limited to 'azalea-physics/src')
| -rw-r--r-- | azalea-physics/src/collision/mod.rs | 19 | ||||
| -rw-r--r-- | azalea-physics/src/lib.rs | 14 |
2 files changed, 18 insertions, 15 deletions
diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index 5d3da699..de9439ca 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -60,7 +60,12 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics) let collided_movement = if movement.length_sqr() == 0.0 { *movement } else { - collide_bounding_box(movement, &entity_bounding_box, world, entity_collisions.clone()) + collide_bounding_box( + movement, + &entity_bounding_box, + world, + entity_collisions.clone(), + ) }; let x_collision = movement.x != collided_movement.x; @@ -70,9 +75,8 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics) let on_ground = physics.on_ground || y_collision && movement.y < 0.; let max_up_step = 0.6; - if on_ground && (x_collision || z_collision) { - let mut hypothetical_new_position - = collide_bounding_box( + if on_ground && (x_collision || z_collision) { + let mut hypothetical_new_position = collide_bounding_box( &Vec3 { x: movement.x, y: max_up_step, @@ -104,12 +108,15 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics) entity_collisions.clone(), ) .add(step_up_position); - if var11.horizontal_distance_sqr() > hypothetical_new_position.horizontal_distance_sqr() { + if var11.horizontal_distance_sqr() > hypothetical_new_position.horizontal_distance_sqr() + { hypothetical_new_position = var11; } } - if hypothetical_new_position.horizontal_distance_sqr() > collided_movement.horizontal_distance_sqr() { + if hypothetical_new_position.horizontal_distance_sqr() + > collided_movement.horizontal_distance_sqr() + { return hypothetical_new_position.add(collide_bounding_box( &Vec3 { x: 0., diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index 50b2c11b..9ff605b9 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -33,15 +33,11 @@ impl Plugin for PhysicsPlugin { app.add_event::<ForceJumpEvent>() .add_systems( Update, - force_jump_listener.after(azalea_entity::clamp_look_direction), + handle_force_jump + .after(azalea_entity::clamp_look_direction) + .before(azalea_entity::update_bounding_box), ) - .add_systems( - FixedUpdate, - (ai_step, travel) - .chain() - .in_set(PhysicsSet) - .after(azalea_entity::update_bounding_box), - ); + .add_systems(FixedUpdate, (ai_step, travel).chain().in_set(PhysicsSet)); } } @@ -173,7 +169,7 @@ pub fn ai_step( #[derive(Event)] pub struct ForceJumpEvent(pub Entity); -pub fn force_jump_listener( +pub fn handle_force_jump( mut query: Query<( &mut Physics, &Position, |
