Merge pull request #1689 from rdbtCVS/t3/d001fd2c

Slow Falling clears the fall distance so landing does not hurt
This commit is contained in:
Ludovic Marie
2026-10-25 14:11:43 +01:00
committed by GitHub
+45
View File
@@ -1758,6 +1758,11 @@ impl EntityMoveWorld for MotionWorld<'_, '_, '_> {
state: BlockStateId,
position: BlockPos,
) -> Result<()> {
// LivingEntity.aiStep: Slow Falling and Levitation reset the fall
// distance every tick, so landing under either does not hurt.
if self.player.status.slow_falling || self.player.status.levitation.is_some() {
self.player.fall_distance = 0.0;
}
if self.player.spawn_extra_particles_on_fall && grounded && self.player.fall_distance > 0.0
{
self.player.events.push(MotionEvent::SmashLanding {
@@ -2918,6 +2923,46 @@ mod tests {
}
}
#[test]
fn slow_falling_clears_the_fall_distance_so_landing_does_not_hurt() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("movement-properties.nbt").exists() {
return;
}
let assets = Assets::load(&root).unwrap();
let render = assets.reload(&root).unwrap();
let binding = crate::collisions::load(&root, assets.registry).unwrap();
let resources = MotionResources::load(&root, &assets).unwrap();
for slow_falling in [false, true] {
let mut scene = World::test_scene(&assets, &render, 2).unwrap();
let mut player = PlayerMotion::new(&resources, Vec3::new(20.5, 9.0, 20.5)).unwrap();
player.fall_distance = 30.0;
player.status.slow_falling = slow_falling;
let mut w = MotionWorld {
entities: &[],
player: &mut player,
scene: &mut scene,
assets: &assets,
collision_binding: &binding,
resources: &resources,
};
for _ in 0..200 {
if w.player.ground.on_ground {
break;
}
w.player_movement_tick([0.0, 0.0], false).unwrap();
}
assert!(w.player.ground.on_ground);
if slow_falling {
assert_eq!(w.player.health.health(), 20.0);
assert_eq!(w.player.fall_distance, 0.0);
} else {
assert!(w.player.health.health() < 20.0);
}
}
}
#[test]
fn a_riptide_spin_lies_flat_and_ends_on_the_first_entity_it_touches() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")