[PR #4332] [MERGED] Combat: the hurt player hears its own hurt sound (single player and multiplayer) #5567

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4332
Author: @WhyFovius
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/player-hurt-sound


📝 Commits (1)

  • b3f866c Combat: the hurt player hears the own hurt sound again

📊 Changes

2 files changed (+113 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+7 -1)
📝 crates/horizon-client/src/game/remote.rs (+106 -2)

📄 Description

🤖 Opened by WhyFovius's AI agent (Claude), not by WhyFovius personally.

Fixes #4149.

What was wrong

In the server-thread architecture the window is a client of its own server through the memory pipe, exactly like a LAN guest. When a player takes damage:

  • the server-side Game (built with Audio::silent, as every server is) received MotionEvent::HurtSound and played it into that silent audio — nobody heard anything;
  • the client's ClientboundDamageEventPacket handler restarted the hurt flash but never played the hurt sound, although vanilla's LivingEntity.handleDamageEvent plays it there.

So in multiplayer there was no sound at all, and in single player the correct hurt sound was equally missing (whatever stood in for it came from elsewhere). The old comment on the DamageEvent arm ("its hurt sound comes as a sound from Horizon's host, which plays it itself") described neither of the two paths.

What vanilla does

Checked against the 26.3 jar bytecode:

  • ClientPacketListener.handleDamageEvent → LivingEntity.handleDamageEvent: jolt the walk animation, restart the hurt flash, and play the hurt sound on the hurt entity's own client — Player.getHurtSound is the damage type's DamageEffects.sound(), at getSoundVolume() (1.0) with a pitch of 1.0 + (rand.nextFloat() - rand.nextFloat()) * 0.2; Player.getSoundSource() is PLAYERS.
  • The server's LivingEntity.playHurtSound → Entity.playSound → ServerLevel.playSeededSound sends a ClientboundSoundPacket to every player around but the hurt one (the Player source is the exception in PlayerList.broadcast).

The fix

  • remote.rs: C::DamageEvent for the local player now resolves the packet's damage type through the synchronized minecraft:damage_type registry and the damage catalog, and plays hurt_sound(effects) at the player's position, volume 1.0, pitch 1.0 ± 0.2 on the level random, on the players channel. An unknown id falls back to the codec's default effects (hurt).
  • lan_actions.rs: tick_guests's MotionEvent::HurtSound now sends the sound through host.hub.sound(..., Some(conn)) — every player around hears it except the hurt one, whose own client just played it. Same split the death sound and the honey-block slide already use.

The lookup is unit-tested (the_hurt_sound_follows_the_damage_events_type: five damage types with distinct effects, plus the unknown-id fallback); the effects → sound mapping itself was already covered by hurt_sounds_follow_damage_effects.

Self-check

pr_ready (tools/pr_ready.py --quick on Windows, against origin/main at 9a0e71859, 1 min 5 s)

Check Result
Scope ✅ 2 files, +113 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (39 s)
rustfmt ✅ (6 s)
clippy ✅ (3 s)
tests: horizon-client ❌ 730 passed, 1 failed (13 s)
doc tests ✅ 0 passed (1 s)
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
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The one failing test, title::tests::each_world_preset_writes_its_own_generator, fails identically on a clean checkout of origin/main on this machine (Windows os error 267, "not a directory", in title/tests.rs:963; it writes a world under a temp path). title/ is untouched by this PR — an environment-local, pre-existing failure.

🤖 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/4332 **Author:** [@WhyFovius](https://github.com/WhyFovius) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/player-hurt-sound` --- ### 📝 Commits (1) - [`b3f866c`](https://github.com/horizon-rust/horizon/commit/b3f866c5a612a9bb37011a585102e2dd2598d0e7) Combat: the hurt player hears the own hurt sound again ### 📊 Changes **2 files changed** (+113 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+7 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+106 -2) </details> ### 📄 Description > 🤖 Opened by WhyFovius's AI agent (Claude), not by WhyFovius personally. Fixes #4149. ## What was wrong In the server-thread architecture the window is a client of its own server through the memory pipe, exactly like a LAN guest. When a player takes damage: - the server-side `Game` (built with `Audio::silent`, as every server is) received `MotionEvent::HurtSound` and played it into that silent audio — nobody heard anything; - the client's `ClientboundDamageEventPacket` handler restarted the hurt flash but never played the hurt sound, although vanilla's `LivingEntity.handleDamageEvent` plays it there. So in multiplayer there was no sound at all, and in single player the correct hurt sound was equally missing (whatever stood in for it came from elsewhere). The old comment on the `DamageEvent` arm ("its hurt sound comes as a sound from Horizon's host, which plays it itself") described neither of the two paths. ## What vanilla does Checked against the 26.3 jar bytecode: - `ClientPacketListener.handleDamageEvent` → `LivingEntity.handleDamageEvent`: jolt the walk animation, restart the hurt flash, and **play the hurt sound on the hurt entity's own client** — `Player.getHurtSound` is the damage type's `DamageEffects.sound()`, at `getSoundVolume()` (1.0) with a pitch of `1.0 + (rand.nextFloat() - rand.nextFloat()) * 0.2`; `Player.getSoundSource()` is `PLAYERS`. - The server's `LivingEntity.playHurtSound` → `Entity.playSound` → `ServerLevel.playSeededSound` sends a `ClientboundSoundPacket` to every player around **but the hurt one** (the `Player` source is the exception in `PlayerList.broadcast`). ## The fix - `remote.rs`: `C::DamageEvent` for the local player now resolves the packet's damage type through the synchronized `minecraft:damage_type` registry and the damage catalog, and plays `hurt_sound(effects)` at the player's position, volume 1.0, pitch `1.0 ± 0.2` on the level random, on the players channel. An unknown id falls back to the codec's default effects (`hurt`). - `lan_actions.rs`: `tick_guests`'s `MotionEvent::HurtSound` now sends the sound through `host.hub.sound(..., Some(conn))` — every player around hears it except the hurt one, whose own client just played it. Same split the death sound and the honey-block slide already use. The lookup is unit-tested (`the_hurt_sound_follows_the_damage_events_type`: five damage types with distinct effects, plus the unknown-id fallback); the effects → sound mapping itself was already covered by `hurt_sounds_follow_damage_effects`. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Windows, against origin/main at 9a0e71859, 1 min 5 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +113 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (39 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (3 s) | | tests: horizon-client | ❌ 730 passed, 1 failed (13 s) | | doc tests | ✅ 0 passed (1 s) | | 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 | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The one failing test, `title::tests::each_world_preset_writes_its_own_generator`, fails identically on a clean checkout of origin/main on this machine (Windows `os error 267`, "not a directory", in `title/tests.rs:963`; it writes a world under a temp path). `title/` is untouched by this PR — an environment-local, pre-existing failure. 🤖 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-03 05:13:27 +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#5567
No description provided.