[PR #4264] [MERGED] A tame pet's death tells its owner how it died #5528

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4264
Author: @d3grando
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3514-pet-death-message


📝 Commits (4)

  • df71f96 A tame pet's death tells its owner how it died
  • e66a24e lan_e2e: pet_death check for the owner's death message
  • 381a1ec Merge hr/main into fix-3514-pet-death-message
  • fdc4a8b Merge remote-tracking branch 'hr/main' into fix/pr-4264

📊 Changes

7 files changed (+331 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/combat.rs (+136 -1)
📝 crates/horizon-client/src/game/commands.rs (+10 -0)
📝 crates/horizon-client/src/game/creatures.rs (+6 -1)
📝 crates/horizon-client/src/lan/hub.rs (+12 -0)
📝 crates/horizon-client/src/mobs.rs (+27 -1)
➕ crates/horizon-client/src/mobs/combat.rs (+95 -0)
📝 tools/lan_e2e.py (+45 -0)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

When a tamed wolf, cat or parrot died, its owner got no chat message. In vanilla, TamableAnimal.die sends the owner the pet's CombatTracker.getDeathMessage(), for example "Rex was slain by Zombie". It does this when showDeathMessages is on and the owner is online in any dimension. Horizon's mobs had no combat tracker, and mob_died had no TamableAnimal.die step, so the owner never heard anything.

The fix:

  • A combat tracker for mobs (mobs::combat). Mob::damage records each hit that reaches the health. A hit taken by wolf armor is not recorded (Wolf.actuallyHurt). Each entry keeps the damage, the fall distance and whether the mob was in water. LivingEntity.tick's recheckStatus forgets the hits after 100 ticks, or 300 during a fight. /kill records its generic_kill hit, as LivingEntity.kill does, so a killed pet reads "Tom was killed".
  • The message goes to the owner. In mob_died, a tame wolf, cat, parrot, nautilus or zombie nautilus sends a message to its owner. The owner can be the in-frame host or a guest, matched by UUID in any dimension, so the server thread works too. The message comes from the existing getDeathMessage code (combat_death_message_for), run on the pet's own hits. That code also handles the fall variants, the kill credit (getKillCredit) and .item. A creeper that blew up has already left the mob list, so its name is kept for the tick ("Boom was blown up by Creeper"). A blast with a cause is player_explosion, as in DamageSources.explosion.
  • /damage … by <player> now makes that player the mob's lastHurtByPlayer, as LivingEntity.hurtServer does. The kill credit and the death message then name that player.

Not covered: Horizon does not track lastClimbablePos for mobs, so the only fall location a pet's message can use is water. Horizon runs a mob's death at the next entity tick, so the owner's line comes just after a command's own feedback (Applied 100.0 damage to Rex), where vanilla sends it during the hit.

Part of #3514: the TamableAnimal.die row of that tracking issue.

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

Checked with javap on the 26.3 client jar:

  • TamableAnimal.die: with GameRules.SHOW_DEATH_MESSAGES, getOwner() as a ServerPlayer, then sendSystemMessage(getCombatTracker().getDeathMessage()) before Animal.die. Wolf.die calls it too.
  • OwnableEntity.getOwner and EntityReference.getEntity: the owner is looked up through Level.getEntityInAnyDimension.
  • CombatTracker.recordDamage, recheckStatus, getDeathMessage, getMostSignificantFall and shouldEnterCombat, plus FallLocation.getCurrentFallLocation.
  • LivingEntity.actuallyHurt (records only a nonzero hit), LivingEntity.tick (recheckStatus), LivingEntity.kill (generic_kill, Float.MAX_VALUE) and LivingEntity.hurtServer (lastHurtByPlayer).
  • DamageSources.explosion (player_explosion when the blast has a cause) and AbstractArrow.onHitEntity (an arrow nobody shot is its own cause).

The new LAN end-to-end check tools/lan_e2e.py --check pet_death covers it. It sets up a guest's wolf slain by a zombie and the host's cat killed with /kill. Only each pet's owner should see the message.

Self-check

tools/pr_ready.py does not run on Windows (it needs SIGHUP), so I ran its steps by hand on Windows 11, rebased on bb6406719:

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib mobs::: 151 passed, 0 failed, 6 ignored. This includes the two new mobs::combat tests: old_hits_are_forgotten_after_100_ticks_or_300_in_a_fight and a_dead_mob_keeps_its_hits_for_its_death_message.
  • cargo test -p horizon-client --bin horizon-client -- combat damage death kill: 4 passed.
  • python tools/lan_e2e.py --check pet_death (through a Windows wrapper, server-thread host plus a guest):
    • On main with only the check added: FAIL, the wolf's owner was not told. The guest's chat had "Applied 100.0 damage to Rex" and no death line.
    • With the fix: PASS. The guest sees "Rex was slain by Zombie" and the host does not. The host sees "Tom was killed" and the guest does not.
  • python tools/lan_e2e.py --check pet_death --check kills --check pvp with the fix: all three PASS.
  • python tools/test_command_exec_parity.py (vanilla oracle against Horizon, covering /kill and /damage): total: 906/906 commands match.
  • In game (single player, server thread): I tested a named wolf slain by a zombie, a cat killed with /kill ("Tom was killed"), a wolf killed by a creeper ("Boom was blown up by Creeper") and a player's hit ("Wolf was slain by …"). A stray wolf with no owner sends nothing.

Screenshots

after: a named tame wolf (Rex) killed by a zombie: its owner gets Rex was slain by Zombie, as TamableAnimal.die sends

The same view and time of day, single player on the server thread: a tamed wolf named Rex, owned by the player, is killed by a zombie (/damage … by the zombie).

  • Before: the chat shows only "Applied 100.0 damage to Rex". The owner is not told.
  • After: the chat also shows "Rex was slain by Zombie".

🤖 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/4264 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3514-pet-death-message` --- ### 📝 Commits (4) - [`df71f96`](https://github.com/horizon-rust/horizon/commit/df71f965b046ef9718fc98a67555ceeaf3954d89) A tame pet's death tells its owner how it died - [`e66a24e`](https://github.com/horizon-rust/horizon/commit/e66a24edd4382785af0bdec4c47699a811a6abd0) lan_e2e: pet_death check for the owner's death message - [`381a1ec`](https://github.com/horizon-rust/horizon/commit/381a1ec66e73a8f4e6f3aa54114bac1935c2064b) Merge hr/main into fix-3514-pet-death-message - [`fdc4a8b`](https://github.com/horizon-rust/horizon/commit/fdc4a8b80e0f5fc8b300f0fd7d7bd2cf2ab6acff) Merge remote-tracking branch 'hr/main' into fix/pr-4264 ### 📊 Changes **7 files changed** (+331 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/combat.rs` (+136 -1) 📝 `crates/horizon-client/src/game/commands.rs` (+10 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+6 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+12 -0) 📝 `crates/horizon-client/src/mobs.rs` (+27 -1) ➕ `crates/horizon-client/src/mobs/combat.rs` (+95 -0) 📝 `tools/lan_e2e.py` (+45 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why When a tamed wolf, cat or parrot died, its owner got no chat message. In vanilla, `TamableAnimal.die` sends the owner the pet's `CombatTracker.getDeathMessage()`, for example "Rex was slain by Zombie". It does this when `showDeathMessages` is on and the owner is online in any dimension. Horizon's mobs had no combat tracker, and `mob_died` had no `TamableAnimal.die` step, so the owner never heard anything. The fix: - **A combat tracker for mobs** (`mobs::combat`). `Mob::damage` records each hit that reaches the health. A hit taken by wolf armor is not recorded (`Wolf.actuallyHurt`). Each entry keeps the damage, the fall distance and whether the mob was in water. `LivingEntity.tick`'s `recheckStatus` forgets the hits after 100 ticks, or 300 during a fight. `/kill` records its `generic_kill` hit, as `LivingEntity.kill` does, so a killed pet reads "Tom was killed". - **The message goes to the owner.** In `mob_died`, a tame wolf, cat, parrot, nautilus or zombie nautilus sends a message to its owner. The owner can be the in-frame host or a guest, matched by UUID in any dimension, so the server thread works too. The message comes from the existing `getDeathMessage` code (`combat_death_message_for`), run on the pet's own hits. That code also handles the fall variants, the kill credit (`getKillCredit`) and `.item`. A creeper that blew up has already left the mob list, so its name is kept for the tick ("Boom was blown up by Creeper"). A blast with a cause is `player_explosion`, as in `DamageSources.explosion`. - **`/damage … by <player>`** now makes that player the mob's `lastHurtByPlayer`, as `LivingEntity.hurtServer` does. The kill credit and the death message then name that player. Not covered: Horizon does not track `lastClimbablePos` for mobs, so the only fall location a pet's message can use is water. Horizon runs a mob's death at the next entity tick, so the owner's line comes just after a command's own feedback (`Applied 100.0 damage to Rex`), where vanilla sends it during the hit. Part of #3514: the `TamableAnimal.die` row of that tracking issue. ## 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 Checked with javap on the 26.3 client jar: - `TamableAnimal.die`: with `GameRules.SHOW_DEATH_MESSAGES`, `getOwner()` as a `ServerPlayer`, then `sendSystemMessage(getCombatTracker().getDeathMessage())` before `Animal.die`. `Wolf.die` calls it too. - `OwnableEntity.getOwner` and `EntityReference.getEntity`: the owner is looked up through `Level.getEntityInAnyDimension`. - `CombatTracker.recordDamage`, `recheckStatus`, `getDeathMessage`, `getMostSignificantFall` and `shouldEnterCombat`, plus `FallLocation.getCurrentFallLocation`. - `LivingEntity.actuallyHurt` (records only a nonzero hit), `LivingEntity.tick` (`recheckStatus`), `LivingEntity.kill` (`generic_kill`, `Float.MAX_VALUE`) and `LivingEntity.hurtServer` (`lastHurtByPlayer`). - `DamageSources.explosion` (`player_explosion` when the blast has a cause) and `AbstractArrow.onHitEntity` (an arrow nobody shot is its own cause). The new LAN end-to-end check `tools/lan_e2e.py --check pet_death` covers it. It sets up a guest's wolf slain by a zombie and the host's cat killed with `/kill`. Only each pet's owner should see the message. ## Self-check `tools/pr_ready.py` does not run on Windows (it needs SIGHUP), so I ran its steps by hand on Windows 11, rebased on `bb6406719`: - `cargo fmt --all -- --check`: clean. - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib mobs::`: 151 passed, 0 failed, 6 ignored. This includes the two new `mobs::combat` tests: `old_hits_are_forgotten_after_100_ticks_or_300_in_a_fight` and `a_dead_mob_keeps_its_hits_for_its_death_message`. - `cargo test -p horizon-client --bin horizon-client -- combat damage death kill`: 4 passed. - `python tools/lan_e2e.py --check pet_death` (through a Windows wrapper, server-thread host plus a guest): - On main with only the check added: **FAIL**, `the wolf's owner was not told`. The guest's chat had "Applied 100.0 damage to Rex" and no death line. - With the fix: **PASS**. The guest sees "Rex was slain by Zombie" and the host does not. The host sees "Tom was killed" and the guest does not. - `python tools/lan_e2e.py --check pet_death --check kills --check pvp` with the fix: all three PASS. - `python tools/test_command_exec_parity.py` (vanilla oracle against Horizon, covering `/kill` and `/damage`): `total: 906/906 commands match`. - In game (single player, server thread): I tested a named wolf slain by a zombie, a cat killed with `/kill` ("Tom was killed"), a wolf killed by a creeper ("Boom was blown up by Creeper") and a player's hit ("Wolf was slain by …"). A stray wolf with no owner sends nothing. ## Screenshots ![after: a named tame wolf (Rex) killed by a zombie: its owner gets Rex was slain by Zombie, as TamableAnimal.die sends](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3514-pet-death-message-1.png) The same view and time of day, single player on the server thread: a tamed wolf named Rex, owned by the player, is killed by a zombie (`/damage … by` the zombie). - Before: the chat shows only "Applied 100.0 damage to Rex". The owner is not told. - After: the chat also shows "Rex was slain by Zombie". 🤖 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 05:13:12 +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#5528
No description provided.