[PR #4857] [MERGED] death: play the player death sound only once on fatal damage #5895

Closed
opened 2026-11-03 05:15:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4857
Author: @mulareal
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix-death-sound-4570


📝 Commits (1)

  • 1aae74b death: play the player death sound only once on fatal damage

📊 Changes

4 files changed (+40 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+12 -4)
📝 crates/horizon-client/src/game/remote.rs (+10 -2)
📝 crates/horizon-client/src/health.rs (+4 -4)
📝 crates/horizon-client/src/motion.rs (+14 -0)

📄 Description

🤖 Opened by mulareal's AI agent (Antigravity, Gemini), not by mulareal personally.

What

Dying from fall damage, mob attacks, or other fatal hits plays the player death sound once instead of twice. Fixes #4570.

Why

  • Game::lan_flush_effects skipped damage_event for dead mobs (!dead), but sent damage_event for players even when p.health.dead_or_dying() was true. Because guest_die also sends EntityEvent(3) (minecraft:entity.player.death), a fatal hit triggered both C::DamageEvent (minecraft:entity.player.hurt) and C::EntityEvent(3) (minecraft:entity.player.death) on the client.
  • Environment::broadcast_damage queued MotionEvent::HurtSound before living_hurt::hurt_server branched on dead_or_dying, so fatal hits also emitted MotionEvent::HurtSound alongside the death sound.
  • C::EntityEvent(3) played minecraft:entity.player.death with a fixed pitch of 1.0 instead of LivingEntity.handleEntityEvent's 1.0 + (random.nextFloat() - random.nextFloat()) * 0.2 on the player sound source.

Fix

  • Gate player damage_event broadcasts in Game::lan_flush_effects (crates/horizon-client/src/game/lan.rs) on !p.health.dead_or_dying(), matching mob death handling.
  • Move MotionEvent::HurtSound emission from Environment::broadcast_damage to Environment::hurt_sound (crates/horizon-client/src/health.rs) so fatal hits do not queue a hurt sound.
  • Play minecraft:entity.player.death in Game::handle_packet (crates/horizon-client/src/game/remote.rs) via play_on with the LivingEntity.handleEntityEvent random pitch offset.

Checked

  • cargo fmt --all -- --check
  • cargo clippy -p horizon-client --bins --tests -- -D warnings
  • cargo test -p horizon-client --lib motion::tests
  • Manual in-game check: verified fatal fall and mob damage play the death sound once.
Check Result
Scope ✅ 4 files, +40 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed
rustfmt ✅
clippy (horizon-client) ✅
tests: horizon-client ✅ 1167 passed
doc tests ✅ 0 passed
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 Generated with Antigravity


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4857 **Author:** [@mulareal](https://github.com/mulareal) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix-death-sound-4570` --- ### 📝 Commits (1) - [`1aae74b`](https://github.com/horizon-rust/horizon/commit/1aae74b8b18a68876e467cbca59ef74a19cd0d24) death: play the player death sound only once on fatal damage ### 📊 Changes **4 files changed** (+40 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+12 -4) 📝 `crates/horizon-client/src/game/remote.rs` (+10 -2) 📝 `crates/horizon-client/src/health.rs` (+4 -4) 📝 `crates/horizon-client/src/motion.rs` (+14 -0) </details> ### 📄 Description > 🤖 Opened by mulareal's AI agent (Antigravity, Gemini), not by mulareal personally. ## What Dying from fall damage, mob attacks, or other fatal hits plays the player death sound once instead of twice. Fixes #4570. ## Why - `Game::lan_flush_effects` skipped `damage_event` for dead mobs (`!dead`), but sent `damage_event` for players even when `p.health.dead_or_dying()` was `true`. Because `guest_die` also sends `EntityEvent(3)` (`minecraft:entity.player.death`), a fatal hit triggered both `C::DamageEvent` (`minecraft:entity.player.hurt`) and `C::EntityEvent(3)` (`minecraft:entity.player.death`) on the client. - `Environment::broadcast_damage` queued `MotionEvent::HurtSound` before `living_hurt::hurt_server` branched on `dead_or_dying`, so fatal hits also emitted `MotionEvent::HurtSound` alongside the death sound. - `C::EntityEvent(3)` played `minecraft:entity.player.death` with a fixed pitch of `1.0` instead of `LivingEntity.handleEntityEvent`'s `1.0 + (random.nextFloat() - random.nextFloat()) * 0.2` on the player sound source. ## Fix - Gate player `damage_event` broadcasts in `Game::lan_flush_effects` (`crates/horizon-client/src/game/lan.rs`) on `!p.health.dead_or_dying()`, matching mob death handling. - Move `MotionEvent::HurtSound` emission from `Environment::broadcast_damage` to `Environment::hurt_sound` (`crates/horizon-client/src/health.rs`) so fatal hits do not queue a hurt sound. - Play `minecraft:entity.player.death` in `Game::handle_packet` (`crates/horizon-client/src/game/remote.rs`) via `play_on` with the `LivingEntity.handleEntityEvent` random pitch offset. ## Checked - `cargo fmt --all -- --check` - `cargo clippy -p horizon-client --bins --tests -- -D warnings` - `cargo test -p horizon-client --lib motion::tests` - Manual in-game check: verified fatal fall and mob damage play the death sound once. | Check | Result | |---|---| | Scope | ✅ 4 files, +40 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed | | rustfmt | ✅ | | clippy (`horizon-client`) | ✅ | | tests: horizon-client | ✅ 1167 passed | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 Generated with [Antigravity](https://antigravity.google) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5895
No description provided.