[PR #662] [MERGED] Network players keep advancements, statistics and a recipe book on the server #2709

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

📋 Pull Request Information

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

Base: main ← Head: feat/network-player-progress


📝 Commits (2)

  • 6154eb9 Network players keep advancements, statistics and a recipe book on the server
  • f58a9bd Merge remote-tracking branch 'origin/main' into feat/network-player-progress

📊 Changes

11 files changed (+682 additions, -180 deletions)

View changed files

📝 crates/horizon-client/src/advancements.rs (+58 -0)
📝 crates/horizon-client/src/game/advancements.rs (+59 -49)
📝 crates/horizon-client/src/game/dedicated.rs (+7 -0)
📝 crates/horizon-client/src/game/lan.rs (+72 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+58 -0)
📝 crates/horizon-client/src/game/scoreboard.rs (+21 -8)
📝 crates/horizon-client/src/game/stats.rs (+98 -46)
📝 crates/horizon-client/src/lan/advancements.rs (+198 -66)
📝 crates/horizon-client/src/lan/guest.rs (+19 -0)
📝 crates/horizon-client/src/lan/hub.rs (+90 -11)
📝 crates/horizon-client/src/lan/playerdata.rs (+2 -0)

📄 Description

What and why

Gaps 1 and 2 of making single player's server thread the default (#495, #494): network players had no advancements, statistics or recipe book on the server. That covers single player on --server-thread (the window is a network player), LAN guests and dedicated server players. This PR is the server side; the window reading these packets is the next PR (#655 is its first part).

Design. The game's advancement, statistic and recipe code is written for one player and already runs a network player's actions through it with that player's state swapped in (as_guest). This adds the player's progress to what is swapped, so every trigger, award, /advancement, /recipe and statistic call site works for them unchanged:

  • Guest keeps PlayerAdvancements (progress, whether it came from the file, what the client was last told is visible, progressChanged), its ServerRecipeBook (read from and written to the player file's recipeBook) and the recipes unlocked since the last packet. GuestPlay keeps its ServerStatsCounter.
  • Files: players/advancements/<uuid>.json and players/stats/<uuid>.json, loaded on joining and saved with the player (leaving, world save, server stop). An integrated server's owner keeps single player's files, so a world opens with the same progress in either mode. A server with no player of its own (dedicated, integrated) no longer loads, ticks or saves advancements and statistics for a phantom host: before this, triggers outside a player's action could land on that phantom and rewrite the owner's file.
  • Ticks: each tick runs Player.tick's counters and the tick, location and inventory triggers for each player. Each move counts checkMovementStatistics. Then PlayerAdvancements.flushDirty sends ClientboundUpdateAdvancementsPacket with what became visible or hidden and the progress that changed.
  • First packet: a new player gets the same first tick as before, byte for byte (the dedicated_server transcript). That first tick now also records the criteria it grants and the recipes it unlocks. A returning player gets their saved advancements (reset, everything visible, their progress with its saved dates).
  • Announcements: PlayerList.broadcastSystemMessage names the player, for everyone. Toasts are the client's.
  • Statistics: ClientboundAwardStatsPacket on REQUEST_STATS, with the dirty statistics. Everything is dirty after joining (markAllDirty). The scoreboard's statistic criteria follow the player's own name.
  • Recipe book: sendInitialRecipeBook on joining (each book's open and filter flags, every known recipe, highlighted while not yet displayed). Recipes unlocked later go out in ClientboundRecipeBookAddPacket with their notification. The entries are the ones ServerAdvancements could already encode (crafting recipes with one display). Other kinds stay a known gap.

Vanilla reference

PlayerAdvancements (load, save, award, flushDirty), ServerStatsCounter (parseLocal, save, markAllDirty, sendStats), ServerRecipeBook (addRecipes, sendInitialRecipeBook), PlayerList.placeNewPlayer, ServerGamePacketListenerImpl.handleClientCommand, ServerPlayer.tick.

Checks

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 793 passed, 0 failed. New: saved_dates_read_back_to_their_instant.
  • By hand (--server-thread, new creative world, offscreen): /give @s crafting_table completes story/root. /advancement grant @s only minecraft:story/mine_stone broadcasts "Player94530 has made the advancement [Stone Age]". After save and quit, the files hold story/root, story/mine_stone and recipes/decorations/crafting_table done, and play_time 109. On reopening, the progress is still there, /advancement revoke takes effect, and play_time carries on to 206.
  • Local parity: running on the integration commit of #655 and this PR. Results to follow in a comment.

skip-release until single player uses the server thread by default.

🤖 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/662 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/network-player-progress` --- ### 📝 Commits (2) - [`6154eb9`](https://github.com/horizon-rust/horizon/commit/6154eb95c345b3c78bd97c1ba3604e47755caa67) Network players keep advancements, statistics and a recipe book on the server - [`f58a9bd`](https://github.com/horizon-rust/horizon/commit/f58a9bdf295b84adef9e844bd626cec0abb8d82b) Merge remote-tracking branch 'origin/main' into feat/network-player-progress ### 📊 Changes **11 files changed** (+682 additions, -180 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/advancements.rs` (+58 -0) 📝 `crates/horizon-client/src/game/advancements.rs` (+59 -49) 📝 `crates/horizon-client/src/game/dedicated.rs` (+7 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+72 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+58 -0) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+21 -8) 📝 `crates/horizon-client/src/game/stats.rs` (+98 -46) 📝 `crates/horizon-client/src/lan/advancements.rs` (+198 -66) 📝 `crates/horizon-client/src/lan/guest.rs` (+19 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+90 -11) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+2 -0) </details> ### 📄 Description ## What and why Gaps 1 and 2 of making single player's server thread the default (#495, #494): network players had no advancements, statistics or recipe book on the server. That covers single player on `--server-thread` (the window is a network player), LAN guests and dedicated server players. This PR is the server side; the window reading these packets is the next PR (#655 is its first part). **Design.** The game's advancement, statistic and recipe code is written for one player and already runs a network player's actions through it with that player's state swapped in (`as_guest`). This adds the player's progress to what is swapped, so every trigger, award, `/advancement`, `/recipe` and statistic call site works for them unchanged: - `Guest` keeps `PlayerAdvancements` (progress, whether it came from the file, what the client was last told is visible, `progressChanged`), its `ServerRecipeBook` (read from and written to the player file's `recipeBook`) and the recipes unlocked since the last packet. `GuestPlay` keeps its `ServerStatsCounter`. - **Files:** `players/advancements/<uuid>.json` and `players/stats/<uuid>.json`, loaded on joining and saved with the player (leaving, world save, server stop). An integrated server's owner keeps single player's files, so a world opens with the same progress in either mode. A server with no player of its own (dedicated, integrated) no longer loads, ticks or saves advancements and statistics for a phantom host: before this, triggers outside a player's action could land on that phantom and rewrite the owner's file. - **Ticks:** each tick runs `Player.tick`'s counters and the tick, location and inventory triggers for each player. Each move counts `checkMovementStatistics`. Then `PlayerAdvancements.flushDirty` sends `ClientboundUpdateAdvancementsPacket` with what became visible or hidden and the progress that changed. - **First packet:** a new player gets the same first tick as before, byte for byte (the `dedicated_server` transcript). That first tick now also records the criteria it grants and the recipes it unlocks. A returning player gets their saved advancements (reset, everything visible, their progress with its saved dates). - **Announcements:** `PlayerList.broadcastSystemMessage` names the player, for everyone. Toasts are the client's. - **Statistics:** `ClientboundAwardStatsPacket` on `REQUEST_STATS`, with the dirty statistics. Everything is dirty after joining (`markAllDirty`). The scoreboard's statistic criteria follow the player's own name. - **Recipe book:** `sendInitialRecipeBook` on joining (each book's open and filter flags, every known recipe, highlighted while not yet displayed). Recipes unlocked later go out in `ClientboundRecipeBookAddPacket` with their notification. The entries are the ones `ServerAdvancements` could already encode (crafting recipes with one display). Other kinds stay a known gap. ## Vanilla reference `PlayerAdvancements` (`load`, `save`, `award`, `flushDirty`), `ServerStatsCounter` (`parseLocal`, `save`, `markAllDirty`, `sendStats`), `ServerRecipeBook` (`addRecipes`, `sendInitialRecipeBook`), `PlayerList.placeNewPlayer`, `ServerGamePacketListenerImpl.handleClientCommand`, `ServerPlayer.tick`. ## Checks - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 793 passed, 0 failed. New: `saved_dates_read_back_to_their_instant`. - By hand (`--server-thread`, new creative world, offscreen): `/give @s crafting_table` completes `story/root`. `/advancement grant @s only minecraft:story/mine_stone` broadcasts "Player94530 has made the advancement [Stone Age]". After save and quit, the files hold `story/root`, `story/mine_stone` and `recipes/decorations/crafting_table` done, and `play_time` 109. On reopening, the progress is still there, `/advancement revoke` takes effect, and `play_time` carries on to 206. - Local parity: running on the integration commit of #655 and this PR. Results to follow in a comment. `skip-release` until single player uses the server thread by default. 🤖 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:58:26 +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#2709
No description provided.