[PR #5058] [MERGED] fix(combat): name a player's renamed held item in death messages #6031

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

📋 Pull Request Information

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

Base: main ← Head: fix/death-message-held-item


📝 Commits (3)

  • 8516e8d fix(combat): name a player's renamed held item in death messages
  • 02e7c4b Merge origin/main: rocket damage now goes through Damage::fireworks
  • 8017536 Merge origin/main into fix/death-message-held-item (main's clippy fix #5304)

📊 Changes

3 files changed (+124 additions, -14 deletions)

View changed files

📝 crates/horizon-client/src/game/combat.rs (+112 -12)
📝 crates/horizon-client/src/game/fireworks.rs (+7 -1)
📝 crates/horizon-client/src/game/lan_pvp.rs (+5 -1)

📄 Description

What and why

The .item death messages (death.attack.player.item, death.attack.arrow.item, death.attack.fireworks.item...) only ever named a mob's held item
mob_main_hand_name looked the cause up in the mob list, so a player holding a renamed item never got the .item form
Vanilla reads the causing entity's main-hand stack, and any LivingEntity counts, players included
The condition is a non-empty stack with the custom_name component, not any non-empty stack
The fix is general: every damage type with a .item key gets it from the same path
A pet killed by a player's sword, arrow or rocket now tells its owner the player's renamed item (was slain by %2$s using %3$s)
For a guest, on LAN or a server thread, the item is read from the guest's own hotbar between turns
A player killed by another player's melee hit now gets death.attack.player.item when the attacker's weapon is renamed, for the host and for guests
The fall messages now have their .item forms too: death.fell.assist.item and death.fell.finish.item (getMessageForAssistedFall), for mobs and players
A player's rocket now marks the mobs it hurts as hurt by that player (setLastHurtByPlayer), as every other player damage does
Without that a guest's rocket kill named nobody, since a server thread has no player in place when the mob dies
A guest's rocket kill now counts for that guest, not the host: their statistics, score and advancements, and a villager's reputation, as in vanilla
A unit test checks the condition: a renamed stack names its item
A stack with other components, or an empty one, does not

Left as is: a player's arrow, trident, rocket, sweep or thorns on another player records no causing player on main (#4690 adds it), so those deaths have no .item form yet
Left as is: for a player's death the item is the one held when the hit landed
Vanilla reads it when the message is built, which only differs when the attacker switches items between a knock-off hit and the fall that kills
Left as is: the host's item is not found while a guest's turn is in place
The swap keeps the host's hotbar slot elsewhere during that turn
Left as is: a rocket still hurts mobs as explosion on main, so the pet reads death.attack.explosion.player.item until #4997 lands
After #4997 it reads death.attack.fireworks.item with no change here

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

DamageSource.getLocalizedDeathMessage takes the causing entity's getMainHandItem() and uses <msgId>.item when !held.isEmpty() && held.has(DataComponents.CUSTOM_NAME) (world/damagesource/DamageSource.java:86-90)
CombatTracker.getMessageForAssistedFall does the same for death.fell.assist.item and death.fell.finish.item (world/damagesource/CombatTracker.java:57-63,68-75)
LivingEntity.resolvePlayerResponsibleForDamage calls setLastHurtByPlayer(player, 100) for any source whose entity is a player (world/entity/LivingEntity.java:1374-1378)
FireworkRocketEntity.dealExplosionDamage hurts with damageSources().fireworks(this, getOwner()) (world/entity/projectile/FireworkRocketEntity.java:253), which makes the owner the causing entity (world/damagesource/DamageSources.java:227)
Lang: every death.*.item key in en_us.json (arrow, explosion.player, fireball, fireworks, indirectMagic, mace_smash, mob, onFire, player, sonic_boom, spear, sting, sulfurCubeHot, thorns, thrown, trident, witherSkull, fell.assist, fell.finish) is reached by appending .item to the plain key

Other projects' code

none

Self-check

Check Result
Scope ✅ 3 files, +124 −14
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 16 s)
rustfmt ✅ (8 s)
clippy ✅ (2 min 5 s)
tests: horizon-client ✅ 1341 passed (5 min 33 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)

🔄 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/5058 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/death-message-held-item` --- ### 📝 Commits (3) - [`8516e8d`](https://github.com/horizon-rust/horizon/commit/8516e8d3f990ac4361a233e2e3d244e68cd72195) fix(combat): name a player's renamed held item in death messages - [`02e7c4b`](https://github.com/horizon-rust/horizon/commit/02e7c4b24ad55e2e72a91588f0ed4dd6a9283ec7) Merge origin/main: rocket damage now goes through Damage::fireworks - [`8017536`](https://github.com/horizon-rust/horizon/commit/8017536dc0a6d7d0c979912a7d7a5fd51b846f7d) Merge origin/main into fix/death-message-held-item (main's clippy fix #5304) ### 📊 Changes **3 files changed** (+124 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/combat.rs` (+112 -12) 📝 `crates/horizon-client/src/game/fireworks.rs` (+7 -1) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+5 -1) </details> ### 📄 Description ## What and why The `.item` death messages (`death.attack.player.item`, `death.attack.arrow.item`, `death.attack.fireworks.item`...) only ever named a mob's held item `mob_main_hand_name` looked the cause up in the mob list, so a player holding a renamed item never got the `.item` form Vanilla reads the causing entity's main-hand stack, and any `LivingEntity` counts, players included The condition is a non-empty stack with the `custom_name` component, not any non-empty stack The fix is general: every damage type with a `.item` key gets it from the same path A pet killed by a player's sword, arrow or rocket now tells its owner the player's renamed item (`was slain by %2$s using %3$s`) For a guest, on LAN or a server thread, the item is read from the guest's own hotbar between turns A player killed by another player's melee hit now gets `death.attack.player.item` when the attacker's weapon is renamed, for the host and for guests The fall messages now have their `.item` forms too: `death.fell.assist.item` and `death.fell.finish.item` (`getMessageForAssistedFall`), for mobs and players A player's rocket now marks the mobs it hurts as hurt by that player (`setLastHurtByPlayer`), as every other player damage does Without that a guest's rocket kill named nobody, since a server thread has no player in place when the mob dies A guest's rocket kill now counts for that guest, not the host: their statistics, score and advancements, and a villager's reputation, as in vanilla A unit test checks the condition: a renamed stack names its item A stack with other components, or an empty one, does not Left as is: a player's arrow, trident, rocket, sweep or thorns on another player records no causing player on `main` (#4690 adds it), so those deaths have no `.item` form yet Left as is: for a player's death the item is the one held when the hit landed Vanilla reads it when the message is built, which only differs when the attacker switches items between a knock-off hit and the fall that kills Left as is: the host's item is not found while a guest's turn is in place The swap keeps the host's hotbar slot elsewhere during that turn Left as is: a rocket still hurts mobs as `explosion` on `main`, so the pet reads `death.attack.explosion.player.item` until #4997 lands After #4997 it reads `death.attack.fireworks.item` with no change here ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `DamageSource.getLocalizedDeathMessage` takes the causing entity's `getMainHandItem()` and uses `<msgId>.item` when `!held.isEmpty() && held.has(DataComponents.CUSTOM_NAME)` (`world/damagesource/DamageSource.java:86-90`) `CombatTracker.getMessageForAssistedFall` does the same for `death.fell.assist.item` and `death.fell.finish.item` (`world/damagesource/CombatTracker.java:57-63,68-75`) `LivingEntity.resolvePlayerResponsibleForDamage` calls `setLastHurtByPlayer(player, 100)` for any source whose entity is a player (`world/entity/LivingEntity.java:1374-1378`) `FireworkRocketEntity.dealExplosionDamage` hurts with `damageSources().fireworks(this, getOwner())` (`world/entity/projectile/FireworkRocketEntity.java:253`), which makes the owner the causing entity (`world/damagesource/DamageSources.java:227`) Lang: every `death.*.item` key in `en_us.json` (`arrow`, `explosion.player`, `fireball`, `fireworks`, `indirectMagic`, `mace_smash`, `mob`, `onFire`, `player`, `sonic_boom`, `spear`, `sting`, `sulfurCubeHot`, `thorns`, `thrown`, `trident`, `witherSkull`, `fell.assist`, `fell.finish`) is reached by appending `.item` to the plain key ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 3 files, +124 −14 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 16 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (2 min 5 s) | | tests: horizon-client | ✅ 1341 passed (5 min 33 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:45 +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#6031
No description provided.