[PR #470] [MERGED] LAN: PvP between the host and guests #2588

Closed
opened 2026-11-02 15:57:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/lan-pvp


📝 Commits (5)

  • dac18e8 LAN: mobs target and attack guests
  • 327aa5a tools/lan_e2e.py: a world with commands, so the guest's commands run again
  • 600bae5 LAN guest: hurt by lava, fire, drowning, suffocation and the void; hungry from moving
  • 2e12123 tools/lan_e2e.py: hazards counts the food spent from full health
  • 36d7f02 LAN: PvP between the host and guests

📊 Changes

13 files changed (+753 additions, -60 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+56 -36)
📝 crates/horizon-client/src/game/creatures.rs (+74 -9)
📝 crates/horizon-client/src/game/hand.rs (+1 -0)
📝 crates/horizon-client/src/game/lan.rs (+10 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+68 -9)
➕ crates/horizon-client/src/game/lan_mobs.rs (+264 -0)
➕ crates/horizon-client/src/game/lan_pvp.rs (+110 -0)
📝 crates/horizon-client/src/game/remote.rs (+6 -0)
📝 crates/horizon-client/src/lan/guest.rs (+3 -0)
📝 crates/horizon-client/src/lan/hub.rs (+3 -0)
📝 crates/horizon-client/src/lan/playerdata.rs (+2 -1)
📝 crates/horizon-client/src/motion/environment.rs (+21 -1)
📝 tools/lan_e2e.py (+135 -4)

📄 Description

Part of #435 (third item: no PvP). Stacked on #467: merge #466, #467, then this.

What vanilla does

Player.attack on a player: the attacker's weapon and effects scaled by the attack strength, a mace's smash, the critical hit (×1.5) and enchantments; the attack charge resets, 0.1 exhaustion, the swing. The victim takes a player_attack hit (shield, armour, knockback) unless ServerPlayer.canHarmPlayer refuses it, which checks isPvpAllowed (the pvp game rule in 26.3). Then the strong / weak / crit / nodamage sound.

What this changes (game/lan_pvp.rs)

  • The host's crosshair targets guests (entity_targeted, guest_hit), and attack() hits the guest when no mob or block is nearer.
  • A guest's ServerboundAttack on the host's entity or another guest's lands on them.
  • The damage formula moves out of attack() into Game::melee_damage, used by both mob and player hits; the ray/box test moves out of mob_hit into ray_box.
  • Hurting a guest and sending them the knockback is one helper now (guest_hit_by), shared with the mob hits of #466.

Not covered: arrows between players (a projectile's owner is Who::Player for the host and for guests alike, so it can't tell them apart yet), and scoreboard-team friendly fire.

How it was verified

  • Two real clients on this Mac (host + guest, offscreen): new pvp check in tools/lan_e2e.py. With iron swords at full charge, the guest hits the host 20 → 14 and the host hits the guest 20 → 14 (both read as 14.83 after one regeneration tick), and with gamerule pvp false a guest hit does nothing. mobs still passes.
  • fmt, cargo clippy -p horizon-client --all-targets -- -D warnings. Parity harnesses: one tools/parity.py --changed origin/main run on the branch combining this series (results on the last PR).

🤖 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/470 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/lan-pvp` --- ### 📝 Commits (5) - [`dac18e8`](https://github.com/horizon-rust/horizon/commit/dac18e8350600d38c4c6b95d987d4738b802185f) LAN: mobs target and attack guests - [`327aa5a`](https://github.com/horizon-rust/horizon/commit/327aa5af6e710b1aa0e3e10652ce0453943b6710) tools/lan_e2e.py: a world with commands, so the guest's commands run again - [`600bae5`](https://github.com/horizon-rust/horizon/commit/600bae5703d222c7b1bd3c51ee8e72b3be12557e) LAN guest: hurt by lava, fire, drowning, suffocation and the void; hungry from moving - [`2e12123`](https://github.com/horizon-rust/horizon/commit/2e1212346f411c06657dec6a68b35ea853430502) tools/lan_e2e.py: hazards counts the food spent from full health - [`36d7f02`](https://github.com/horizon-rust/horizon/commit/36d7f02802889397f0d3c1d71fffbd15a2025f54) LAN: PvP between the host and guests ### 📊 Changes **13 files changed** (+753 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+56 -36) 📝 `crates/horizon-client/src/game/creatures.rs` (+74 -9) 📝 `crates/horizon-client/src/game/hand.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+10 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+68 -9) ➕ `crates/horizon-client/src/game/lan_mobs.rs` (+264 -0) ➕ `crates/horizon-client/src/game/lan_pvp.rs` (+110 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+2 -1) 📝 `crates/horizon-client/src/motion/environment.rs` (+21 -1) 📝 `tools/lan_e2e.py` (+135 -4) </details> ### 📄 Description Part of #435 (third item: no PvP). Stacked on #467: merge #466, #467, then this. ## What vanilla does `Player.attack` on a player: the attacker's weapon and effects scaled by the attack strength, a mace's smash, the critical hit (×1.5) and enchantments; the attack charge resets, 0.1 exhaustion, the swing. The victim takes a `player_attack` hit (shield, armour, knockback) unless `ServerPlayer.canHarmPlayer` refuses it, which checks `isPvpAllowed` (the `pvp` game rule in 26.3). Then the strong / weak / crit / nodamage sound. ## What this changes (game/lan_pvp.rs) - The host's crosshair targets guests (`entity_targeted`, `guest_hit`), and `attack()` hits the guest when no mob or block is nearer. - A guest's `ServerboundAttack` on the host's entity or another guest's lands on them. - The damage formula moves out of `attack()` into `Game::melee_damage`, used by both mob and player hits; the ray/box test moves out of `mob_hit` into `ray_box`. - Hurting a guest and sending them the knockback is one helper now (`guest_hit_by`), shared with the mob hits of #466. Not covered: arrows between players (a projectile's owner is `Who::Player` for the host and for guests alike, so it can't tell them apart yet), and scoreboard-team friendly fire. ## How it was verified - **Two real clients on this Mac** (host + guest, offscreen): new `pvp` check in `tools/lan_e2e.py`. With iron swords at full charge, the guest hits the host 20 → 14 and the host hits the guest 20 → 14 (both read as 14.83 after one regeneration tick), and with `gamerule pvp false` a guest hit does nothing. `mobs` still passes. - fmt, `cargo clippy -p horizon-client --all-targets -- -D warnings`. Parity harnesses: one `tools/parity.py --changed origin/main` run on the branch combining this series (results on the last PR). 🤖 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-02 15:57:25 +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#2588
No description provided.