[PR #216] [MERGED] Play the player's hurt sound for every damage, by its damage effects (#144) #2413

Closed
opened 2026-11-02 15:55:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/216
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/berry-prick-sound-144


📝 Commits (1)

  • bf7b3d1 Play the player's hurt sound for every damage, by its damage effects (#144)

📊 Changes

5 files changed (+63 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/audio.rs (+5 -0)
📝 crates/horizon-client/src/game.rs (+4 -3)
📝 crates/horizon-client/src/game/combat.rs (+14 -0)
📝 crates/horizon-client/src/game/creatures.rs (+0 -3)
📝 crates/horizon-client/src/health.rs (+40 -1)

📄 Description

Fixes #144

Root cause. In vanilla, the hurt sound is played by the client when the server broadcasts the damage event: LivingEntity.hurtServer calls ServerLevel.broadcastDamageEvent, the client's LivingEntity.handleDamageEvent plays getHurtSound(source) at pitch (r - r) * 0.2 + 1, and Player.getHurtSound is source.type().effects().sound(). Sweet berry bushes use effects: poking, which plays entity.player.hurt_sweet_berry_bush. Horizon only played entity.player.hurt by hand, for falls and mob hits. Berry bushes, fire and lava, drowning, freezing, cactus and the other sources made no sound.

Fix.

  • The combat port's broadcast_damage now emits HealthEvent::DamageBroadcast { source } instead of the bare broadcast-damage phase. The trace line is unchanged, so the scene-motion and health harnesses see the same output.
  • When the game drains the player's motion events, it plays health::hurt_sound(definition.effects), the DamageEffects table: hurt and thorns play entity.player.hurt, drowning hurt_drown, burning hurt_on_fire, poking hurt_sweet_berry_bush, freezing hurt_freeze. The pitch comes from the audio's client random, not the world random. The two hand-written plays (falls, mob hits) are removed so nothing plays twice. The death sound is still played separately, as in vanilla.

Evidence.

  • Unit test: the full DamageEffects → sound table.
  • In game on a vscreen, with audio to a PipeWire null sink: walking through grown berry bushes in survival, the sound census (status.sounds.events) shows minecraft:entity.player.hurt_sweet_berry_bush on every prick while health drops. Before this change no hurt sound played at all.
  • Mac mini: fmt and workspace clippy -D warnings are clean; 518 lib tests pass.

Leftover, not part of this issue: ClientboundDamageEventPacket isn't implemented, so LAN guests and players on servers hear no hurt sounds of their own.

🤖 Generated with Claude Code


🔄 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/216 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/berry-prick-sound-144` --- ### 📝 Commits (1) - [`bf7b3d1`](https://github.com/horizon-rust/horizon/commit/bf7b3d140f8da83540a4f555a80e90b5efce44a9) Play the player's hurt sound for every damage, by its damage effects (#144) ### 📊 Changes **5 files changed** (+63 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/audio.rs` (+5 -0) 📝 `crates/horizon-client/src/game.rs` (+4 -3) 📝 `crates/horizon-client/src/game/combat.rs` (+14 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+0 -3) 📝 `crates/horizon-client/src/health.rs` (+40 -1) </details> ### 📄 Description Fixes #144 **Root cause.** In vanilla, the hurt sound is played by the client when the server broadcasts the damage event: `LivingEntity.hurtServer` calls `ServerLevel.broadcastDamageEvent`, the client's `LivingEntity.handleDamageEvent` plays `getHurtSound(source)` at pitch `(r - r) * 0.2 + 1`, and `Player.getHurtSound` is `source.type().effects().sound()`. Sweet berry bushes use `effects: poking`, which plays `entity.player.hurt_sweet_berry_bush`. Horizon only played `entity.player.hurt` by hand, for falls and mob hits. Berry bushes, fire and lava, drowning, freezing, cactus and the other sources made no sound. **Fix.** - The combat port's `broadcast_damage` now emits `HealthEvent::DamageBroadcast { source }` instead of the bare `broadcast-damage` phase. The trace line is unchanged, so the scene-motion and health harnesses see the same output. - When the game drains the player's motion events, it plays `health::hurt_sound(definition.effects)`, the `DamageEffects` table: hurt and thorns play `entity.player.hurt`, drowning `hurt_drown`, burning `hurt_on_fire`, poking `hurt_sweet_berry_bush`, freezing `hurt_freeze`. The pitch comes from the audio's client random, not the world random. The two hand-written plays (falls, mob hits) are removed so nothing plays twice. The death sound is still played separately, as in vanilla. **Evidence.** - Unit test: the full `DamageEffects` → sound table. - In game on a vscreen, with audio to a PipeWire null sink: walking through grown berry bushes in survival, the sound census (`status.sounds.events`) shows `minecraft:entity.player.hurt_sweet_berry_bush` on every prick while health drops. Before this change no hurt sound played at all. - Mac mini: fmt and workspace `clippy -D warnings` are clean; 518 lib tests pass. Leftover, not part of this issue: `ClientboundDamageEventPacket` isn't implemented, so LAN guests and players on servers hear no hurt sounds of their own. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:52 +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#2413
No description provided.