[PR #4624] [MERGED] Send a team leave before the join that moves a player #5736

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4624
Author: @AurelienBelloir
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: parity/team-packets-to-guests


📝 Commits (1)

  • 9b47769 Send a team leave before the join that moves a player

📊 Changes

2 files changed (+43 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+5 -1)
📝 crates/horizon-client/src/lan/scoreboard.rs (+38 -9)

📄 Description

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

What and why

Most of #3520's team rows were already on main: the team packets reach every guest, a new joiner gets all teams, and death messages follow deathMessageVisibility. One ordering bug was left.

  • lan/scoreboard.rs View::changes: every team leave (method 4) now goes out before any add, modify or join. Vanilla ServerScoreboard.addPlayerToTeam sends the old team's leave first. A vanilla client's Scoreboard.removePlayerFromTeam(name, team) throws IllegalStateException when the player is already in another team, which happened when a player moved to a team whose name sorts earlier (red to blue).
  • game/remote.rs remote_team: a leave now only takes the player out of the named team, as vanilla's removePlayerFromTeam(name, team) does. Before, it took the player out of whatever team they were in, so the bad order above removed them from their new team.
  • Tests: added a_player_moving_teams_leaves_the_old_one_first and updated the expected order in teams_go_to_everyone_with_their_players.

Fixes #4623

Not covered: Two small differences are left on purpose because the board is synced by diffing. First, a change to deathMessageVisibility alone sends no method-2 packet: vanilla's onTeamChanged would send one, but its Parameters don't carry that field, so the client ends up in the same state. Second, changes made within one tick are merged into one diff instead of being sent one packet per change. I did not check the TeamColor ids (0-15, absent for no colour) against TeamColor.STREAM_CODEC in this pass; the existing code and its round-trip test already assume them.

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

Read from the 26.3 bytecode with javap -c:

  • net.minecraft.server.level.ServerPlayer.die
  • net.minecraft.server.players.PlayerList.broadcastSystemToTeam
  • net.minecraft.server.players.PlayerList.broadcastSystemToAllExceptTeam
  • net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket.createAddOrModifyPacket
  • net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket.createPlayerPacket
  • net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket$Parameters.STREAM_CODEC
  • net.minecraft.client.multiplayer.ClientPacketListener.handleSetPlayerTeamPacket
  • net.minecraft.world.scores.Scoreboard.removePlayerFromTeam

Tests added or extended:

  • lan::scoreboard::tests::a_player_moving_teams_leaves_the_old_one_first

No new parity harness.

Self-check

The full tools/pr_ready.py needs more disk than this machine has (see #4543). Checked by hand on Windows, with prepared 26.3 resources in HORIZON_RESOURCES (CARGO_INCREMENTAL=0):

  • rustfmt: ✅
  • cargo clippy -p horizon-client --all-targets -- -D warnings: ✅
  • cargo test --no-fail-fast -p horizon-client --lib --bins --tests: horizon-client lib 781 passed, 1 failed: title::tests::each_world_preset_writes_its_own_generator, which fails on Windows only and already fails on main; #4544 fixes it; horizon-client bin 240 passed; horizon-ctl 18 passed; all 8 integration suites pass
  • Public tree hook: ✅
  • An independent review against the 26.3 bytecode before opening; its findings are fixed in this branch.

🤖 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/4624 **Author:** [@AurelienBelloir](https://github.com/AurelienBelloir) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `parity/team-packets-to-guests` --- ### 📝 Commits (1) - [`9b47769`](https://github.com/horizon-rust/horizon/commit/9b4776975767807d46bc7839d07ea1882fce597e) Send a team leave before the join that moves a player ### 📊 Changes **2 files changed** (+43 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+5 -1) 📝 `crates/horizon-client/src/lan/scoreboard.rs` (+38 -9) </details> ### 📄 Description > 🤖 Opened by AurelienBelloir's AI agent (Claude Code, Claude Opus 5.5), not by AurelienBelloir personally. ## What and why Most of #3520's team rows were already on main: the team packets reach every guest, a new joiner gets all teams, and death messages follow deathMessageVisibility. One ordering bug was left. - `lan/scoreboard.rs` `View::changes`: every team leave (method 4) now goes out before any add, modify or join. Vanilla `ServerScoreboard.addPlayerToTeam` sends the old team's leave first. A vanilla client's `Scoreboard.removePlayerFromTeam(name, team)` throws `IllegalStateException` when the player is already in another team, which happened when a player moved to a team whose name sorts earlier (red to blue). - `game/remote.rs` `remote_team`: a leave now only takes the player out of the named team, as vanilla's `removePlayerFromTeam(name, team)` does. Before, it took the player out of whatever team they were in, so the bad order above removed them from their new team. - Tests: added `a_player_moving_teams_leaves_the_old_one_first` and updated the expected order in `teams_go_to_everyone_with_their_players`. Fixes #4623 Not covered: Two small differences are left on purpose because the board is synced by diffing. First, a change to deathMessageVisibility alone sends no method-2 packet: vanilla's onTeamChanged would send one, but its Parameters don't carry that field, so the client ends up in the same state. Second, changes made within one tick are merged into one diff instead of being sent one packet per change. I did not check the TeamColor ids (0-15, absent for no colour) against TeamColor.STREAM_CODEC in this pass; the existing code and its round-trip test already assume them. ## 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 Read from the 26.3 bytecode with `javap -c`: - `net.minecraft.server.level.ServerPlayer.die` - `net.minecraft.server.players.PlayerList.broadcastSystemToTeam` - `net.minecraft.server.players.PlayerList.broadcastSystemToAllExceptTeam` - `net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket.createAddOrModifyPacket` - `net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket.createPlayerPacket` - `net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket$Parameters.STREAM_CODEC` - `net.minecraft.client.multiplayer.ClientPacketListener.handleSetPlayerTeamPacket` - `net.minecraft.world.scores.Scoreboard.removePlayerFromTeam` Tests added or extended: - `lan::scoreboard::tests::a_player_moving_teams_leaves_the_old_one_first` No new parity harness. ## Self-check The full `tools/pr_ready.py` needs more disk than this machine has (see #4543). Checked by hand on Windows, with prepared 26.3 resources in `HORIZON_RESOURCES` (`CARGO_INCREMENTAL=0`): - rustfmt: ✅ - `cargo clippy -p horizon-client --all-targets -- -D warnings`: ✅ - `cargo test --no-fail-fast -p horizon-client --lib --bins --tests`: horizon-client lib 781 passed, 1 failed: `title::tests::each_world_preset_writes_its_own_generator`, which fails on Windows only and already fails on main; #4544 fixes it; horizon-client bin 240 passed; horizon-ctl 18 passed; all 8 integration suites pass - Public tree hook: ✅ - An independent review against the 26.3 bytecode before opening; its findings are fixed in this branch. 🤖 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:14:39 +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#5736
No description provided.