[PR #1728] [MERGED] Server thread: remove forgotten recipes from the client's book #3720

Closed
opened 2026-11-03 04:11:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: t3/7a98935a


📝 Commits (4)

  • 859236b Fix recipe removal notifications for server players
  • 09e95ae Merge main: keep both appended lan_e2e checks
  • b165506 Recipe book: removeRecipes returns the display ids it removed, as vanilla
  • 9dfdff9 Merge main into t3/7a98935a: keep both sides' appended checks

📊 Changes

5 files changed (+87 additions, -8 deletions)

View changed files

📝 crates/horizon-client/examples/probe/recipe_book_fixture.rs (+1 -1)
📝 crates/horizon-client/src/game/commands/world_cmds.rs (+9 -1)
📝 crates/horizon-client/src/lan/hub.rs (+3 -1)
📝 crates/horizon-client/src/recipe_book.rs (+6 -4)
📝 tools/lan_e2e.py (+68 -1)

📄 Description

🤖 Opened by rdbt's AI agent (OpenCode, agentrouter/gpt-6.1-sol), not by rdbt personally.

What and why

Fixes #1495.

/recipe take updated the server's recipe book without notifying connected clients, leaving forgotten recipes visible until reconnecting.

  • Queue RecipeBookRemove with the display IDs of recipes actually forgotten, including every display of a multi-display recipe.
  • Filter deferred recipe additions against the player's current book so a grant followed by a take before the flush cannot restore a forgotten recipe.
  • Add the recipe_removal LAN E2E check for the host and guest: wildcard removal with the book open, reopening, later grants, individual removals, and re-granting.

Vanilla reference

Minecraft 26.3's net.minecraft.stats.ServerRecipeBook.removeRecipes and lambda$removeRecipes$0, read from the pinned server-game jar with javap -c -p. Vanilla considers only known recipes, removes their highlights, collects every RecipeDisplayEntry.id, and sends ClientboundRecipeBookRemovePacket when that list is nonempty. ServerRecipeBook.addRecipes sends additions immediately; filtering Horizon's deferred additions preserves the final book when recipes are taken before its flush.

Self-check

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 89f426c48, 14 min 1 s)

Check Result
Scope ✅ 3 files, +85 −3
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 252 passed (2 min 6 s)
rustfmt ✅ (35 s)
clippy ✅ (1 min 23 s)
tests: horizon-client ✅ 1201 passed (8 min 48 s)
doc tests ✅ 0 passed (9 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 188 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 176 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The final self-check used an isolated build directory. The local prepared-resource view includes the vanilla registry and command reports.

Additional checks with a fast build, fresh game/launcher/XDG homes, and an offscreen Xvfb driver:

Host path Existing recipes check New recipe_removal check
In-frame ✅ Recipe placement works ✅ Host 52 → 0 displays; guest 4 → 0
Server thread ✅ Recipe placement works ✅ Host and guest each 4 → 0 displays

Both players in both runs also keep zero displays after reopening, receive two later grants, drop to one after an individual take, then zero after the last take, and receive a re-grant normally. A pre-fix build reproduces the bug: four displays remain after the server reports taking five recipes.

To run the checks in the usual harness environment:

cargo build --locked --profile fast -p horizon-client --bins
python3 tools/lan_e2e.py --bin-dir target/fast --check recipes --check recipe_removal
python3 tools/lan_e2e.py --bin-dir target/fast --server-thread --check recipes --check recipe_removal

Screenshots

The regression captures before-removal, empty-book, and re-granted-book screenshots for each player in its --out directory (host-/guest-recipe-removal-{before,empty,granted}.png). The pre-fix server-thread snapshot after taking all recipes still shows four buttons; the fixed snapshot shows an empty book.

🤖 Generated with OpenCode (agentrouter/gpt-6.1-sol).


🔄 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/1728 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3/7a98935a` --- ### 📝 Commits (4) - [`859236b`](https://github.com/horizon-rust/horizon/commit/859236bd9da591444d9e18b137692993585a18d0) Fix recipe removal notifications for server players - [`09e95ae`](https://github.com/horizon-rust/horizon/commit/09e95ae5a12319f90ed380475899638819dd7f2a) Merge main: keep both appended lan_e2e checks - [`b165506`](https://github.com/horizon-rust/horizon/commit/b165506d6e97caf0a84c9f57f3393a1a96480a57) Recipe book: removeRecipes returns the display ids it removed, as vanilla - [`9dfdff9`](https://github.com/horizon-rust/horizon/commit/9dfdff9d629ec0222cb648ca3766976c088c57b5) Merge main into t3/7a98935a: keep both sides' appended checks ### 📊 Changes **5 files changed** (+87 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/recipe_book_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+9 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+3 -1) 📝 `crates/horizon-client/src/recipe_book.rs` (+6 -4) 📝 `tools/lan_e2e.py` (+68 -1) </details> ### 📄 Description > 🤖 Opened by rdbt's AI agent (OpenCode, agentrouter/gpt-6.1-sol), not by rdbt personally. ## What and why Fixes #1495. `/recipe take` updated the server's recipe book without notifying connected clients, leaving forgotten recipes visible until reconnecting. - Queue `RecipeBookRemove` with the display IDs of recipes actually forgotten, including every display of a multi-display recipe. - Filter deferred recipe additions against the player's current book so a grant followed by a take before the flush cannot restore a forgotten recipe. - Add the `recipe_removal` LAN E2E check for the host and guest: wildcard removal with the book open, reopening, later grants, individual removals, and re-granting. ## Vanilla reference Minecraft 26.3's `net.minecraft.stats.ServerRecipeBook.removeRecipes` and `lambda$removeRecipes$0`, read from the pinned server-game jar with `javap -c -p`. Vanilla considers only known recipes, removes their highlights, collects every `RecipeDisplayEntry.id`, and sends `ClientboundRecipeBookRemovePacket` when that list is nonempty. `ServerRecipeBook.addRecipes` sends additions immediately; filtering Horizon's deferred additions preserves the final book when recipes are taken before its flush. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 89f426c48, 14 min 1 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +85 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 252 passed (2 min 6 s) | | rustfmt | ✅ (35 s) | | clippy | ✅ (1 min 23 s) | | tests: horizon-client | ✅ 1201 passed (8 min 48 s) | | doc tests | ✅ 0 passed (9 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 188 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 176 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The final self-check used an isolated build directory. The local prepared-resource view includes the vanilla registry and command reports. Additional checks with a fast build, fresh game/launcher/XDG homes, and an offscreen Xvfb driver: | Host path | Existing `recipes` check | New `recipe_removal` check | | --- | --- | --- | | In-frame | ✅ Recipe placement works | ✅ Host 52 → 0 displays; guest 4 → 0 | | Server thread | ✅ Recipe placement works | ✅ Host and guest each 4 → 0 displays | Both players in both runs also keep zero displays after reopening, receive two later grants, drop to one after an individual take, then zero after the last take, and receive a re-grant normally. A pre-fix build reproduces the bug: four displays remain after the server reports taking five recipes. To run the checks in the usual harness environment: ```sh cargo build --locked --profile fast -p horizon-client --bins python3 tools/lan_e2e.py --bin-dir target/fast --check recipes --check recipe_removal python3 tools/lan_e2e.py --bin-dir target/fast --server-thread --check recipes --check recipe_removal ``` ## Screenshots The regression captures before-removal, empty-book, and re-granted-book screenshots for each player in its `--out` directory (`host-`/`guest-recipe-removal-{before,empty,granted}.png`). The pre-fix server-thread snapshot after taking all recipes still shows four buttons; the fixed snapshot shows an empty book. 🤖 Generated with [OpenCode](https://opencode.ai) (agentrouter/gpt-6.1-sol). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:11:42 +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#3720
No description provided.