[PR #1858] [MERGED] Server: death messages come from the player's own combat record #3820

Closed
opened 2026-11-03 04:12:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/server-death-messages


📝 Commits (3)

  • feec1b6 Server deaths: build the message from the player's own combat record
  • 70aff6e Death screen: empty message with showDeathMessages off; forget a guest's record when they leave
  • e37770b Merge remote-tracking branch 'origin/main' into cg14/pr1858

📊 Changes

6 files changed (+76 additions, -31 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/combat.rs (+5 -1)
📝 crates/horizon-client/src/game/lan.rs (+1 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+61 -24)
📝 crates/horizon-client/src/game/remote.rs (+4 -6)
📝 crates/horizon-client/src/game/wither.rs (+2 -0)

📄 Description

🤖 Opened by Excurs1ons's AI agent (OpenCode), not by Excurs1ons himself.

Fixes #1825.

What and why

On a server (server-thread single player, LAN, or dedicated), a guest's death only had death_cause, which /kill alone sets. Every other death fell back to X died or a generic cause, so the chat and the death screen never named what killed the player.

The local player already has a full CombatTracker port (game/combat.rs), fed by the motion events of each tick. This gives each guest their own tracker, swapped in for the duration of their turn and fed by the same motion events, and takes the death message from CombatTracker.getDeathMessage with the dying player's own name.

The death screen also resolved the server's component with the session's en_us table (Remote.lang), so even a correct message came out English. It now resolves with the client's current language, exactly as the chat line does.

Vanilla reference

  • CombatTracker.recordDamage / recheckStatus / getDeathMessage: death.attack.*, the fall variants (death.fell.*) and the .item suffix. The port already existed for the local player; this feeds it per server player.
  • ServerPlayer.die: the message goes to the dying player's death screen and is broadcast unless showDeathMessages or the player's team hides it.
  • WitherSkull.onHitEntity: the skull's owner is the causing entity, so the message is death.attack.witherSkull with the wither's name.
  • ClientboundPlayerCombatKillPacket.message is a Component, resolved with the client's language.

Change

  • Game keeps guest_combat: HashMap<u32, CombatTracker>; enter_guest/leave_guest swap it with combat, so a guest's damage, attacker notes and fall location are theirs and never the host's. A new body (join, respawn, dimension change) starts empty.
  • guest_server_tick records the guest's motion events, including landing damage from the server-side travel, into that tracker.
  • At death, guest_death_message builds the message from the guest's tracker with player_text(name, uuid). /kill keeps its death_cause key; below the world uses death.attack.outOfWorld; otherwise the tracker decides.
  • wither.rs sets projectile_owner before the skull hits a player, so the skull names its wither.
  • remote.rs resolves PlayerCombatKill.message with remote_text (current language) instead of plain(..., &r.lang).
  • The death screen now always receives the message; chat broadcast is still gated by showDeathMessages and the team.

Evidence

Server-thread, lang:zh_cn:

  • Wither skull: chat and death screen both Player44375被凋灵发射的头颅射杀 (the screen used to read Player44375 died).
  • /kill: Player44375被杀死了 (death.attack.genericKill).
  • Wither explosion: 被凋灵炸死了 (death.attack.explosion.player / wither as the attacker).
  • Fall and out-of-world keep their vanilla keys (death.fell.*, death.attack.outOfWorld).

I checked the death screen and the chat line side by side in-game; both show the same text (screenshot available if wanted).

Self-check

pr_ready (tools/pr_ready.py --quick, 4 min 19 s)

Check Result
Scope ✅ 5 files, +72 −32; 104 lines of code (git diff origin/main...HEAD; pr_ready's own count also includes untracked local files)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (6 s)
clippy ❌ failed (16 s) on the pre-existing horizon-world/src/worldgen/aquifer/noise_based.rs:450 manual_range_contains, which also fails on main
tests: horizon-client ❌ 1087 passed, 3 failed, all environmental and the same on main: crash::tests::stacks_start_at_the_panicking_frame (backtrace path), packs::cache::tests::directory_inputs_config_and_owned_output_recovery (PermissionDenied), save::tests::session_lock_is_exclusive (Windows file lock)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher checks ➖ launcher untouched
Parity ➖ not run (--quick): CI picks the affected harnesses

🤖 Generated with OpenCode


🔄 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/1858 **Author:** [@Excurs1ons](https://github.com/Excurs1ons) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/server-death-messages` --- ### 📝 Commits (3) - [`feec1b6`](https://github.com/horizon-rust/horizon/commit/feec1b67e8446f5d81a4418f956b8b6b0f394e1e) Server deaths: build the message from the player's own combat record - [`70aff6e`](https://github.com/horizon-rust/horizon/commit/70aff6e90b1689bd2f365825fa34308aa46e65fa) Death screen: empty message with showDeathMessages off; forget a guest's record when they leave - [`e37770b`](https://github.com/horizon-rust/horizon/commit/e37770bbfe68f30d9cf0b8e9499efc805845c842) Merge remote-tracking branch 'origin/main' into cg14/pr1858 ### 📊 Changes **6 files changed** (+76 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/combat.rs` (+5 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+61 -24) 📝 `crates/horizon-client/src/game/remote.rs` (+4 -6) 📝 `crates/horizon-client/src/game/wither.rs` (+2 -0) </details> ### 📄 Description > 🤖 Opened by Excurs1ons's AI agent (OpenCode), not by Excurs1ons himself. Fixes #1825. ## What and why On a server (server-thread single player, LAN, or dedicated), a guest's death only had `death_cause`, which `/kill` alone sets. Every other death fell back to `X died` or a generic cause, so the chat and the death screen never named what killed the player. The local player already has a full `CombatTracker` port (`game/combat.rs`), fed by the motion events of each tick. This gives each guest their own tracker, swapped in for the duration of their turn and fed by the same motion events, and takes the death message from `CombatTracker.getDeathMessage` with the dying player's own name. The death screen also resolved the server's component with the session's `en_us` table (`Remote.lang`), so even a correct message came out English. It now resolves with the client's current language, exactly as the chat line does. ## Vanilla reference - `CombatTracker.recordDamage` / `recheckStatus` / `getDeathMessage`: `death.attack.*`, the fall variants (`death.fell.*`) and the `.item` suffix. The port already existed for the local player; this feeds it per server player. - `ServerPlayer.die`: the message goes to the dying player's death screen and is broadcast unless `showDeathMessages` or the player's team hides it. - `WitherSkull.onHitEntity`: the skull's owner is the causing entity, so the message is `death.attack.witherSkull` with the wither's name. - `ClientboundPlayerCombatKillPacket.message` is a `Component`, resolved with the client's language. ## Change - `Game` keeps `guest_combat: HashMap<u32, CombatTracker>`; `enter_guest`/`leave_guest` swap it with `combat`, so a guest's damage, attacker notes and fall location are theirs and never the host's. A new body (join, respawn, dimension change) starts empty. - `guest_server_tick` records the guest's motion events, including landing damage from the server-side travel, into that tracker. - At death, `guest_death_message` builds the message from the guest's tracker with `player_text(name, uuid)`. `/kill` keeps its `death_cause` key; below the world uses `death.attack.outOfWorld`; otherwise the tracker decides. - `wither.rs` sets `projectile_owner` before the skull hits a player, so the skull names its wither. - `remote.rs` resolves `PlayerCombatKill.message` with `remote_text` (current language) instead of `plain(..., &r.lang)`. - The death screen now always receives the message; chat broadcast is still gated by `showDeathMessages` and the team. ## Evidence Server-thread, `lang:zh_cn`: - Wither skull: chat and death screen both `Player44375被凋灵发射的头颅射杀` (the screen used to read `Player44375 died`). - `/kill`: `Player44375被杀死了` (`death.attack.genericKill`). - Wither explosion: `被凋灵炸死了` (`death.attack.explosion.player` / wither as the attacker). - Fall and out-of-world keep their vanilla keys (`death.fell.*`, `death.attack.outOfWorld`). I checked the death screen and the chat line side by side in-game; both show the same text (screenshot available if wanted). ## Self-check **pr_ready** (`tools/pr_ready.py --quick`, 4 min 19 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +72 −32; 104 lines of code (`git diff origin/main...HEAD`; pr_ready's own count also includes untracked local files) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (6 s) | | clippy | ❌ failed (16 s) on the pre-existing `horizon-world/src/worldgen/aquifer/noise_based.rs:450` `manual_range_contains`, which also fails on `main` | | tests: horizon-client | ❌ 1087 passed, 3 failed, all environmental and the same on `main`: `crash::tests::stacks_start_at_the_panicking_frame` (backtrace path), `packs::cache::tests::directory_inputs_config_and_owned_output_recovery` (`PermissionDenied`), `save::tests::session_lock_is_exclusive` (Windows file lock) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher checks | ➖ launcher untouched | | Parity | ➖ not run (`--quick`): CI picks the affected harnesses | 🤖 Generated with [OpenCode](https://opencode.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12: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#3820
No description provided.