[PR #310] [MERGED] Shield blocks: the player hears the block sound, not the hurt sound #2478

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

📋 Pull Request Information

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

Base: main ← Head: fix/shield-block-no-hurt-sound


📝 Commits (1)

  • 72ff742 Shield blocks: the player hears the block sound, not the hurt sound

📊 Changes

2 files changed (+48 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/health.rs (+6 -4)
📝 crates/horizon-client/src/motion.rs (+42 -0)

📄 Description

Part of #277. Thanks to Cosmic (Online5277) for the report.

What

When a shield blocks a hit (an arrow, for example), the player now hears the shield's block sound and no longer the player-hurt sound.

Why

In vanilla the player hears their own hurt sound only through LivingEntity.handleDamageEvent, which runs when the server broadcasts the damage event. Player.playSound leaves the player out of the server-side playHurtSound. A blocked hit never broadcasts a damage event: BlocksAttacks.onBlocked plays the blocks_attacks block sound (item.shield.block) instead. Horizon played the hurt sound for every hit that reached hurt, blocked ones included.

How

  • health.rs: the local MotionEvent::HurtSound is now queued together with the damage broadcast, so a blocked hit makes only the block sound.
  • motion.rs test: a shield blocking a 4-damage arrow gives blocked == 4, the block sound and no HurtSound.

How tested

Self-check (Mac mini), all five branches of this batch rebased on origin/main 050b2038:
- cargo fmt --all --check: OK
- cargo clippy --workspace --all-targets -- -D warnings: OK on this branch alone, and on the integration of all five
- cargo test -p horizon-client (integration): 649 + 41 + 15 + 2 + 2 + 1 passed, 0 failed
- tools/parity.py --changed origin/main on the integration commit: 79 passed, 0 failed
  (including arrow, use_item_on, first_person, dispenser and mob_ai)
- tools/parity.py, run explicitly: player_hurt, blocking_rules, blocking_item_damage, item_use, item_use_start,
  item_use_lifecycle, living_hurt, damage_reduction, player_equipment, registered_player_combat,
  server_player_combat, server_player_damage: 12 passed, 0 failed

Screenshots: ~/code/horizon-parity/shots/offhand-276/ on the Mac mini.

Needs Ludovic

Nothing.

🤖 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/310 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/shield-block-no-hurt-sound` --- ### 📝 Commits (1) - [`72ff742`](https://github.com/horizon-rust/horizon/commit/72ff7422737b230bb1da16bcfa731c701aaaa188) Shield blocks: the player hears the block sound, not the hurt sound ### 📊 Changes **2 files changed** (+48 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/health.rs` (+6 -4) 📝 `crates/horizon-client/src/motion.rs` (+42 -0) </details> ### 📄 Description Part of #277. Thanks to Cosmic (Online5277) for the report. ## What When a shield blocks a hit (an arrow, for example), the player now hears the shield's block sound and no longer the player-hurt sound. ## Why In vanilla the player hears their own hurt sound only through `LivingEntity.handleDamageEvent`, which runs when the server broadcasts the damage event. `Player.playSound` leaves the player out of the server-side `playHurtSound`. A blocked hit never broadcasts a damage event: `BlocksAttacks.onBlocked` plays the `blocks_attacks` block sound (`item.shield.block`) instead. Horizon played the hurt sound for every hit that reached `hurt`, blocked ones included. ## How - `health.rs`: the local `MotionEvent::HurtSound` is now queued together with the damage broadcast, so a blocked hit makes only the block sound. - `motion.rs` test: a shield blocking a 4-damage arrow gives `blocked == 4`, the block sound and no `HurtSound`. ## How tested ``` Self-check (Mac mini), all five branches of this batch rebased on origin/main 050b2038: - cargo fmt --all --check: OK - cargo clippy --workspace --all-targets -- -D warnings: OK on this branch alone, and on the integration of all five - cargo test -p horizon-client (integration): 649 + 41 + 15 + 2 + 2 + 1 passed, 0 failed - tools/parity.py --changed origin/main on the integration commit: 79 passed, 0 failed (including arrow, use_item_on, first_person, dispenser and mob_ai) - tools/parity.py, run explicitly: player_hurt, blocking_rules, blocking_item_damage, item_use, item_use_start, item_use_lifecycle, living_hurt, damage_reduction, player_equipment, registered_player_combat, server_player_combat, server_player_damage: 12 passed, 0 failed ``` Screenshots: ~/code/horizon-parity/shots/offhand-276/ on the Mac mini. ## Needs Ludovic Nothing. 🤖 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:56:31 +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#2478
No description provided.