[PR #1002] [MERGED] Play the equip sound when the player puts on armour #2976

Closed
opened 2026-11-02 16:00:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

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


📝 Commits (2)

  • 7426aed Play the equip sound when the player puts on armour
  • 7c06fee Keep the equip list out of the place_recipe oracle's state line

📊 Changes

10 files changed (+311 additions, -49 deletions)

View changed files

📝 crates/horizon-client/examples/menu_fixture.rs (+9 -2)
📝 crates/horizon-client/src/game.rs (+20 -0)
📝 crates/horizon-client/src/game/armor_stands.rs (+13 -17)
📝 crates/horizon-client/src/game/commands/items.rs (+6 -2)
📝 crates/horizon-client/src/game/dispenser.rs (+23 -9)
📝 crates/horizon-client/src/game/lan_actions.rs (+21 -1)
📝 crates/horizon-client/src/game/lan_crafting.rs (+9 -0)
➕ crates/horizon-client/src/game/player_equip.rs (+94 -0)
📝 crates/horizon-client/src/menu.rs (+99 -12)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMenuOracle.java (+17 -6)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #986, reported on Discord by famescare: equipping armour made no sound.

What

Vanilla 26.3's LivingEntity.onEquipItem now runs for the player on every path vanilla calls it from (new game/player_equip.rs):

Path Vanilla Horizon now
Inventory clicks, shift-clicks, number keys, drags, double clicks ArmorSlot.setByPlayer and InventoryMenu's off-hand slot override the menu engine (menu.rs) records each setByPlayer on those slots, with vanilla's previous stack; the host and LAN guests (guest_menu_op) play them
F over a hotbar slot in the inventory the off hand changes through Inventory.setItem: silent silent (only the clicked target slot counts)
Right-click equip Equippable.swapWithEquipmentSlot → setItemSlot same, now with the generic sound for items without equip_sound, and isSameItemSameComponents instead of full equality
Creative screen clicks locally, handleSetCreativeModeSlot sets each changed slot by player every changed armour/off-hand slot (including Shift+destroy); guests' SetCreativeModeSlot too
Swap-hands key (host and guests) setItemInHand off hand, then main hand same
Dispensers onto the player setItemSlot; Player.canUseSlot accepts the off hand same, and a dispensed shield now goes to an empty off hand
/item replace, /item modify, /loot replace on armor.* / weapon.offhand LivingEntity's equipment SlotAccess → setItemSlot same

onEquipItem itself: nothing on a client (remote) or for a spectator, nothing when the item is unchanged; the item's Equippable.equipSound (default item.armor.equip_generic) on PLAYERS at the player when the item's equippable slot is the slot; equip/unequip game events for armour slots only (Player.doesEmitEquipEvent). A save's initial load sets the slots directly, so it stays silent like vanilla's firstTick.

Proof

  • test_menu_click_parity: the Java oracle's stand-in player now records vanilla's onEquipItem calls that change the item (slot + new stack) after every click; the Rust fixture prints the engine's. With the engine's recording disabled (main's behaviour): 7978/8000 cases match, FAIL; with this PR: PASS (8000/8000).
  • New unit test menu::tests::armour_and_off_hand_slots_report_what_is_equipped (shift-click on, pick up, F onto a hotbar slot silent, number key on the off-hand slot).

Self-check (Mac mini)

cargo fmt --all                                             ok
cargo clippy -p horizon-client --all-targets -D warnings    ok (only crate touched)
cargo test -p horizon-client                                923 + 77 + … passed, 0 failed
tools/parity.py menu_click                                  PASS (557 s)
tools/parity.py command_exec creative dispenser lan sculk use_item_on   6 passed, 0 failed

--changed origin/main lists 98 harnesses (game.rs is touched); the six above plus menu_click are the ones on these paths; CI runs the rest.

Not checked by ear: games here run with HORIZON_NO_AUDIO=1, so the sound itself was not heard; the menu events, the default sound and the slot match are what the harness and code cover.

Nothing needs Ludovic.

🤖 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/1002 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/player-equip-sound` --- ### 📝 Commits (2) - [`7426aed`](https://github.com/horizon-rust/horizon/commit/7426aed33c6a6e019f93817f64ee4a5b628c4fbb) Play the equip sound when the player puts on armour - [`7c06fee`](https://github.com/horizon-rust/horizon/commit/7c06feec74348884460975275c304fcc66ff3d8f) Keep the equip list out of the place_recipe oracle's state line ### 📊 Changes **10 files changed** (+311 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/menu_fixture.rs` (+9 -2) 📝 `crates/horizon-client/src/game.rs` (+20 -0) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+13 -17) 📝 `crates/horizon-client/src/game/commands/items.rs` (+6 -2) 📝 `crates/horizon-client/src/game/dispenser.rs` (+23 -9) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+21 -1) 📝 `crates/horizon-client/src/game/lan_crafting.rs` (+9 -0) ➕ `crates/horizon-client/src/game/player_equip.rs` (+94 -0) 📝 `crates/horizon-client/src/menu.rs` (+99 -12) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMenuOracle.java` (+17 -6) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #986, reported on Discord by famescare: equipping armour made no sound. ## What Vanilla 26.3's `LivingEntity.onEquipItem` now runs for the player on every path vanilla calls it from (new `game/player_equip.rs`): | Path | Vanilla | Horizon now | | --- | --- | --- | | Inventory clicks, shift-clicks, number keys, drags, double clicks | `ArmorSlot.setByPlayer` and `InventoryMenu`'s off-hand slot override | the menu engine (`menu.rs`) records each `setByPlayer` on those slots, with vanilla's `previous` stack; the host and LAN guests (`guest_menu_op`) play them | | F over a hotbar slot in the inventory | the off hand changes through `Inventory.setItem`: silent | silent (only the clicked target slot counts) | | Right-click equip | `Equippable.swapWithEquipmentSlot` → `setItemSlot` | same, now with the generic sound for items without `equip_sound`, and `isSameItemSameComponents` instead of full equality | | Creative screen | clicks locally, `handleSetCreativeModeSlot` sets each changed slot by player | every changed armour/off-hand slot (including Shift+destroy); guests' `SetCreativeModeSlot` too | | Swap-hands key (host and guests) | `setItemInHand` off hand, then main hand | same | | Dispensers onto the player | `setItemSlot`; `Player.canUseSlot` accepts the off hand | same, and a dispensed shield now goes to an empty off hand | | `/item replace`, `/item modify`, `/loot replace` on `armor.*` / `weapon.offhand` | `LivingEntity`'s equipment `SlotAccess` → `setItemSlot` | same | `onEquipItem` itself: nothing on a client (`remote`) or for a spectator, nothing when the item is unchanged; the item's `Equippable.equipSound` (default `item.armor.equip_generic`) on `PLAYERS` at the player when the item's equippable slot is the slot; `equip`/`unequip` game events for armour slots only (`Player.doesEmitEquipEvent`). A save's initial load sets the slots directly, so it stays silent like vanilla's `firstTick`. ## Proof - `test_menu_click_parity`: the Java oracle's stand-in player now records vanilla's `onEquipItem` calls that change the item (slot + new stack) after every click; the Rust fixture prints the engine's. With the engine's recording disabled (main's behaviour): **7978/8000 cases match, FAIL**; with this PR: **PASS** (8000/8000). - New unit test `menu::tests::armour_and_off_hand_slots_report_what_is_equipped` (shift-click on, pick up, F onto a hotbar slot silent, number key on the off-hand slot). ## Self-check (Mac mini) ``` cargo fmt --all ok cargo clippy -p horizon-client --all-targets -D warnings ok (only crate touched) cargo test -p horizon-client 923 + 77 + … passed, 0 failed tools/parity.py menu_click PASS (557 s) tools/parity.py command_exec creative dispenser lan sculk use_item_on 6 passed, 0 failed ``` `--changed origin/main` lists 98 harnesses (game.rs is touched); the six above plus `menu_click` are the ones on these paths; CI runs the rest. Not checked by ear: games here run with `HORIZON_NO_AUDIO=1`, so the sound itself was not heard; the menu events, the default sound and the slot match are what the harness and code cover. Nothing needs Ludovic. 🤖 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 16:00:34 +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#2976
No description provided.