From 57213668a0be5f67c68e5864182c8bc72d9db031 Mon Sep 17 00:00:00 2001 From: "minimax-m3.1-flash" Date: Tue, 27 Oct 2026 04:09:25 +0500 Subject: [PATCH] Add a regression test: an arrow kills a player at half a heart The health layer spends the last of the player's health and raises the dead flag, so Game::tick can show the death screen. Co-Authored-By: minimax-m3.1-flash (Claude Code) --- crates/horizon-client/src/health.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/horizon-client/src/health.rs b/crates/horizon-client/src/health.rs index 46821df27..4514c2bcf 100644 --- a/crates/horizon-client/src/health.rs +++ b/crates/horizon-client/src/health.rs @@ -860,6 +860,31 @@ mod tests { assert!(!third.hurt && !third.knockback); } + /// #2141: an arrow that takes the last of the player's health must kill + /// them: `LivingEntity.hurt` leaves the health at zero and `Player.die` + /// follows. + #[test] + fn an_arrow_kills_a_player_at_one_health() { + let root = std::path::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 = crate::assets::Assets::load(&root).unwrap(); + let resources = crate::motion::MotionResources::load(&root, &assets).unwrap(); + let mut player = + crate::motion::PlayerMotion::new(&resources, horizon_core::geometry::Vec3::ZERO) + .unwrap(); + player.set_health(1.0, false).unwrap(); + let (health, rules) = (&resources.health, super::HealthRules::default()); + let id = health.damage.id("minecraft:arrow").unwrap(); + let hurt = player.hurt(health, rules, id, 5.0).unwrap(); + assert!(hurt, "the arrow must hurt"); + assert_eq!(player.health.health(), 0.0, "the health must be spent"); + assert!(player.health.dead_or_dying(), "the player must be dead"); + } + #[test] fn hurt_sounds_follow_damage_effects() { // DamageEffects: HURT, THORNS, DROWNING, BURNING, POKING, FREEZING.