[PR #5392] [MERGED] A player's broken tool, shield or armour breaks for every client #6258

Closed
opened 2026-11-03 06:16:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/player-equipment-break-event


📝 Commits (1)

  • 9aeae19 A player's broken tool, shield or armour is told to every client

📊 Changes

7 files changed (+99 additions, -48 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+25 -23)
📝 crates/horizon-client/src/game/enchant_effects.rs (+6 -18)
📝 crates/horizon-client/src/game/item_particles.rs (+1 -1)
📝 crates/horizon-client/src/game/lan.rs (+44 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+9 -0)
📝 crates/horizon-client/src/game/mounts.rs (+6 -0)
📝 crates/horizon-client/src/game/shield.rs (+8 -6)

📄 Description

🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally.

Part of #3514: the player half of LivingEntity.entityEventForEquipmentBreak. sirrayi's #5317 does the mobs' worn pieces; the last status comment on the issue lists what is left: the player's two hands (47, 48), and a guest's tool breaking on the host. This PR is the players (hands and armour); it does not touch creatures.rs.

Vanilla

ItemStack.hurtAndBreak calls LivingEntity.onEquippedItemBroken(stack, slot), which does level.broadcastEntityEvent(this, entityEventForEquipmentBreak(slot)) (47 main hand, 48 off hand, 49 head, 50 chest, 51 legs, 52 feet, 65 body, 68 saddle). The server plays nothing itself: every client's handleEntityEvent runs breakItem on the stack it still has in that slot (its break_sound component, then the crumbs), the owner's client included. The shield's sound is that component (item.shield.break), not a server sound.

What changes

  • Game::player_equipment_broke(slot, stack) sends the event for the acting player: a guest's breaks are kept in guest_equipment_breaks and broadcast with their entity id when their turn ends (leave_guest, like guest_entity_events); the host's go out through the hub at once. A window that runs the world itself (and no hub at all) plays the break sound and the crumbs here, as a client does.
  • Every break site of the player's own gear uses it: the held tool (damage_held), the worn armour (hurt wear, Thorns, Frost Walker's boots), the shield (from the hand it was used from: 47 or 48) and the carrot on a stick before it becomes a fishing rod. They played entity.item.break (or the shield sound) on the server and the crumbs on the host only; now every client plays the stack's own sound and crumbs.
  • break_sound_at is pub(super) so the local half uses the same component sound.

What it depends on

The saddle (68) and the body slot (65) of a player do not exist (a player has no saddle or body armour); mounts' saddles and mobs' armour are #5317's and the mount code's.

Verification

  • Real run on the server thread (window as a guest, survival): an iron pickaxe at 249 of 250 durability mined a leaf block; it broke (the hand emptied) and the game heard entity.item.break exactly once, from the event (no second sound from the server).
  • pr_ready --quick: rustfmt, clippy, Python tests pass. The only failures are the 8 lan_bot tests, which fail the same way on a clean origin/main here.

🤖 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/5392 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/player-equipment-break-event` --- ### 📝 Commits (1) - [`9aeae19`](https://github.com/horizon-rust/horizon/commit/9aeae198d12444b0780f160b8aaf173d2f4751f6) A player's broken tool, shield or armour is told to every client ### 📊 Changes **7 files changed** (+99 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+25 -23) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+6 -18) 📝 `crates/horizon-client/src/game/item_particles.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+44 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+9 -0) 📝 `crates/horizon-client/src/game/mounts.rs` (+6 -0) 📝 `crates/horizon-client/src/game/shield.rs` (+8 -6) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Part of #3514: the player half of `LivingEntity.entityEventForEquipmentBreak`. `sirrayi`'s #5317 does the mobs' worn pieces; the last status comment on the issue lists what is left: the player's two hands (47, 48), and a guest's tool breaking on the host. This PR is the players (hands and armour); it does not touch `creatures.rs`. ## Vanilla `ItemStack.hurtAndBreak` calls `LivingEntity.onEquippedItemBroken(stack, slot)`, which does `level.broadcastEntityEvent(this, entityEventForEquipmentBreak(slot))` (47 main hand, 48 off hand, 49 head, 50 chest, 51 legs, 52 feet, 65 body, 68 saddle). The server plays nothing itself: every client's `handleEntityEvent` runs `breakItem` on the stack it still has in that slot (its `break_sound` component, then the crumbs), the owner's client included. The shield's sound is that component (`item.shield.break`), not a server sound. ## What changes - `Game::player_equipment_broke(slot, stack)` sends the event for the acting player: a guest's breaks are kept in `guest_equipment_breaks` and broadcast with their entity id when their turn ends (`leave_guest`, like `guest_entity_events`); the host's go out through the hub at once. A window that runs the world itself (and no hub at all) plays the break sound and the crumbs here, as a client does. - Every break site of the player's own gear uses it: the held tool (`damage_held`), the worn armour (`hurt` wear, Thorns, Frost Walker's boots), the shield (from the hand it was used from: 47 or 48) and the carrot on a stick before it becomes a fishing rod. They played `entity.item.break` (or the shield sound) on the server and the crumbs on the host only; now every client plays the stack's own sound and crumbs. - `break_sound_at` is `pub(super)` so the local half uses the same component sound. ## What it depends on The saddle (68) and the body slot (65) of a *player* do not exist (a player has no saddle or body armour); mounts' saddles and mobs' armour are #5317's and the mount code's. ## Verification - Real run on the server thread (window as a guest, survival): an iron pickaxe at 249 of 250 durability mined a leaf block; it broke (the hand emptied) and the game heard `entity.item.break` exactly once, from the event (no second sound from the server). - `pr_ready --quick`: rustfmt, clippy, Python tests pass. The only failures are the 8 `lan_bot` tests, which fail the same way on a clean `origin/main` here. 🤖 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 06:16:29 +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#6258
No description provided.