[PR #7640] Preserve connected player causes in mob command damage #7731

Open
opened 2026-11-03 07:23:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7640
Author: @TheMrZZ
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/guest-command-damage-attacker


📝 Commits (1)

  • 7aa99a1 Preserve connected player causes in mob command damage

📊 Changes

3 files changed (+150 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/execute.rs (+12 -1)
📝 crates/horizon-client/src/game/commands/world_cmds.rs (+51 -9)
📝 tools/lan_e2e.py (+87 -0)

📄 Description

🤖 Opened by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally.

What and why

Fixes #7614. /damage now retains a connected player as the causing entity of a mob hit, including by <cow> from <guest>. /execute on attacker resolves the recorded player's connection instead of assuming the client currently reading the relation is the attacker.

Reuse the existing guest damage context and player binding. Record that connection after an accepted hit, so a refused equal hit retains the previous attacker and an accepted stronger hit replaces it. Mob/no-cause handling and causing-entity priority remain intact.

Adds a real two-client LAN regression, read from both clients with host and guest issuing commands. It covers pig and warden subjects; no cause, cow, host, guest and indirect guest causes; and refused/accepted attacker replacement. Scoreboard markers observe actual relation execution without asserting the unrelated selector-feedback text. World game time must remain frozen throughout the reads.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

Java 26.3 DamageCommand.damage passes the supplied DamageSource into the entity's hurtServer method. The causing entity is DamageSource.getEntity; LivingEntity records it as the last living attacker returned by getLastHurtByMob for execute on attacker. The connection binding adapts that entity identity to Horizon's existing Who::Player representation.

The real LAN baseline fails connected-player identity (a guest reading a host hit resolves themselves). The fixed build passes all 22 cases and 176 attacker identity checks, including direct and indirect guest causes, with health checks and unchanged game time. A fresh live Java/Horizon pair was not rerun locally; the single-player command oracle cannot prove this connected-player route.

No loot, world-generation, selector-feedback wording or sonic damage formula changes or parity claims.

Other projects' code

None.

Self-check

pr_ready (tools/pr_ready.py --quick on a local runner, against origin/main at 97dc1b553, 6 min 13 s)

Check Result
Scope ✅ 3 files, +150 −10
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 614 passed (1 min 22 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 23 s)
tests: horizon-client ✅ 698 passed (1 min 57 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (18 s)
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)

Focused real-client check: lan_e2e.py --check damage-attacker, with locally built debug binaries: PASS (22 cases). port_ledger.py check --base origin/main recognizes the complete command handler; no new gaps.

🤖 Generated with Codex.


🔄 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/7640 **Author:** [@TheMrZZ](https://github.com/TheMrZZ) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/guest-command-damage-attacker` --- ### 📝 Commits (1) - [`7aa99a1`](https://github.com/horizon-rust/horizon/commit/7aa99a177b0887e72bfa833ac44737f99de794b6) Preserve connected player causes in mob command damage ### 📊 Changes **3 files changed** (+150 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/execute.rs` (+12 -1) 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+51 -9) 📝 `tools/lan_e2e.py` (+87 -0) </details> ### 📄 Description > 🤖 Opened by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally. ## What and why Fixes #7614. `/damage` now retains a connected player as the causing entity of a mob hit, including `by <cow> from <guest>`. `/execute on attacker` resolves the recorded player's connection instead of assuming the client currently reading the relation is the attacker. Reuse the existing guest damage context and player binding. Record that connection after an accepted hit, so a refused equal hit retains the previous attacker and an accepted stronger hit replaces it. Mob/no-cause handling and causing-entity priority remain intact. Adds a real two-client LAN regression, read from both clients with host and guest issuing commands. It covers pig and warden subjects; no cause, cow, host, guest and indirect guest causes; and refused/accepted attacker replacement. Scoreboard markers observe actual relation execution without asserting the unrelated selector-feedback text. World game time must remain frozen throughout the reads. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference Java 26.3 `DamageCommand.damage` passes the supplied DamageSource into the entity's hurtServer method. The causing entity is DamageSource.getEntity; LivingEntity records it as the last living attacker returned by getLastHurtByMob for `execute on attacker`. The connection binding adapts that entity identity to Horizon's existing Who::Player representation. The real LAN baseline fails connected-player identity (a guest reading a host hit resolves themselves). The fixed build passes all 22 cases and 176 attacker identity checks, including direct and indirect guest causes, with health checks and unchanged game time. A fresh live Java/Horizon pair was not rerun locally; the single-player command oracle cannot prove this connected-player route. No loot, world-generation, selector-feedback wording or sonic damage formula changes or parity claims. ## Other projects' code None. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on a local runner, against origin/main at 97dc1b553, 6 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +150 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 614 passed (1 min 22 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 23 s) | | tests: horizon-client | ✅ 698 passed (1 min 57 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (18 s) | | 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) | Focused real-client check: `lan_e2e.py --check damage-attacker`, with locally built debug binaries: PASS (22 cases). `port_ledger.py check --base origin/main` recognizes the complete command handler; no new gaps. 🤖 Generated with [Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7731
No description provided.