[PR #1000] [MERGED] Server: players on one team without friendly fire don't hurt each other #2975

Closed
opened 2026-11-02 16:00:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/pvp-friendly-fire


📝 Commits (1)

  • b0c8f96 Server: players on one team without friendly fire don't hurt each other

📊 Changes

2 files changed (+26 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_pvp.rs (+14 -0)
📝 tools/lan_e2e.py (+12 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Part of #484: "team friendly fire is ignored".

What

On a Horizon server, a player hitting another player (the host and a guest, or two guests) only checked the pvp game rule. Vanilla checks more. ServerPlayer.hurtServer refuses a hit from a player that the victim can't be harmed by (canHarmPlayer): the pvp rule, then Player.canHarmPlayer → Entity.doTeamsAllowDamage on the victim's team. If both players are on a team with friendlyFire false, the ally takes no damage and the attacker hears the no-damage sound.

pvp_strike now records the attacker's team. pvp_land asks teams_allow_damage(victim's team, attacker's team), an existing helper in scoreboard.rs, before landing the hit.

Arrows aren't covered: a player's arrows don't hit other players on a server yet. That is listed in #484.

Tested

tools/lan_e2e.py's pvp check (a Horizon host and a Horizon guest) gains two cases. After team add, team modify … friendlyFire false and team join … @a, the guest hits the host and the host hits the guest, and neither may lose health.

  • On main: fails, 'guest hits teammate': (19.33, 13.33) and 'host hits teammate': (19.33, 13.33).
  • With this PR: passes, (19.33, 19.33) both ways. The earlier cases still pass: hits land with pvp on, and nothing happens with pvp off. This ran on an integration build with #998, #999 and #1001.

Self-check

On one integration build of the four #484 PRs (#998, #999, #1000, #1001), on main at dbfaf2e0. The branches sit on ee59df13, which adds only #980's renderer change, which none of them touch:

cargo fmt --all -- --check                                ok (each branch too)
cargo clippy --workspace --all-targets -- -D warnings     ok
cargo test -p horizon-client                              ok: 920 + 77 + 15 + 2 + 2 + 2 + 1 passed, 0 failed
tools/test_dedicated_server_parity.py                     dedicated server: 604 transcript lines identical
tools/lan_e2e.py --check pvp chest crafting containers machines swings eat sign   all pass
tools/lan_e2e.py --check effects recipes projectiles                              all pass

Nothing needs Ludovic.

🤖 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/1000 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/pvp-friendly-fire` --- ### 📝 Commits (1) - [`b0c8f96`](https://github.com/horizon-rust/horizon/commit/b0c8f964b25f84296b2176e824e45b41143a77bd) Server: players on one team without friendly fire don't hurt each other ### 📊 Changes **2 files changed** (+26 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+14 -0) 📝 `tools/lan_e2e.py` (+12 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #484: "team friendly fire is ignored". ## What On a Horizon server, a player hitting another player (the host and a guest, or two guests) only checked the `pvp` game rule. Vanilla checks more. `ServerPlayer.hurtServer` refuses a hit from a player that the victim can't be harmed by (`canHarmPlayer`): the `pvp` rule, then `Player.canHarmPlayer` → `Entity.doTeamsAllowDamage` on the victim's team. If both players are on a team with `friendlyFire false`, the ally takes no damage and the attacker hears the no-damage sound. `pvp_strike` now records the attacker's team. `pvp_land` asks `teams_allow_damage(victim's team, attacker's team)`, an existing helper in `scoreboard.rs`, before landing the hit. Arrows aren't covered: a player's arrows don't hit other players on a server yet. That is listed in #484. ## Tested `tools/lan_e2e.py`'s `pvp` check (a Horizon host and a Horizon guest) gains two cases. After `team add`, `team modify … friendlyFire false` and `team join … @a`, the guest hits the host and the host hits the guest, and neither may lose health. - **On main:** fails, `'guest hits teammate': (19.33, 13.33)` and `'host hits teammate': (19.33, 13.33)`. - **With this PR:** passes, `(19.33, 19.33)` both ways. The earlier cases still pass: hits land with pvp on, and nothing happens with pvp off. This ran on an integration build with #998, #999 and #1001. ## Self-check On one integration build of the four #484 PRs (#998, #999, #1000, #1001), on main at dbfaf2e0. The branches sit on ee59df13, which adds only #980's renderer change, which none of them touch: ``` cargo fmt --all -- --check ok (each branch too) cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client ok: 920 + 77 + 15 + 2 + 2 + 2 + 1 passed, 0 failed tools/test_dedicated_server_parity.py dedicated server: 604 transcript lines identical tools/lan_e2e.py --check pvp chest crafting containers machines swings eat sign all pass tools/lan_e2e.py --check effects recipes projectiles all pass ``` Nothing needs Ludovic. 🤖 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 16:00:33 +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#2975
No description provided.