[PR #7608] Recipe book: a guest's seen recipe stops being highlighted #7712

Open
opened 2026-11-03 07:22:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7608
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/recipe-book-seen


📝 Commits (5)

  • db562ee feat: read ServerboundRecipeBookSeenRecipePacket
  • 00d0bf8 test: the seen recipe is a two-byte display id
  • 1f1e308 feat: a guest's seen recipe clears its highlight
  • 723afba test: a display id names the recipe it was numbered for
  • c69a290 port_map: handleRecipeBookSeenRecipePacket is ported

📊 Changes

5 files changed (+116 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/lan/advancements.rs (+46 -0)
📝 crates/horizon-client/src/lan/hub.rs (+14 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+38 -1)
📝 crates/horizon-protocol/src/packets/recipes.rs (+17 -0)
📝 tools/port_map/rest-018.tsv (+1 -1)

📄 Description

ServerGamePacketListenerImpl.handleRecipeBookSeenRecipePacket asks the recipe manager for the display the client names — getRecipeFromDisplay(recipe.recipe()) (bytecode 12–26) — and, when it finds it, hands the holder's id to player.getRecipeBook().removeHighlight(...) (31–45). ServerRecipeBook.removeHighlight is this.highlight.remove(key) (bytecode 0–11): the recipe stops being one the book announces as new. An id that names no display does nothing.

What Horizon lacked

Two pieces:

  1. horizon-protocol's serverbound play enum had no variant for opcode 48, so the packet read as Serverbound::Unknown(48, ..) and the hub's dispatch (which matches typed variants only) dropped it.
  2. The hub therefore never cleared the guest's toBeDisplayed set, so a recipe the guest had already looked at kept its highlight on the next RecipeBookAdd.

Now packets::recipes::RecipeBookSeenRecipe reads and writes the one VarInt, ServerAdvancements::recipe_of_display is the manager's lookup over the display numbers the server handed out, and the hub's dispatch clears the guest's highlight for the display it names.

Proven: packets::play::tests::a_seen_recipe_is_one_varint_display_id — opcode 48 with AC 02 decodes to display 300 and encodes back to the same two bytes; a one-byte payload is refused; and an id that still has no variant (51, SEEN_ADVANCEMENTS) decodes as Unknown(51, ..), which is exactly what opcode 48 did before this change.

lan::advancements::tests::a_display_id_names_the_recipe_it_was_numbered_for — with two fixture recipes the displays are numbered in id order, so display 0 is minecraft:aaa_shaped, display 1 is minecraft:bbb_smelting, and display 2 is None; the handler asks this and a None clears nothing.

Not proven: the hub's arm itself has no test — a guest connection's inbox has no fixture in this crate, so what runs end to end (a bot sending opcode 48 and being sent a RecipeBookAdd without the highlight) is left to the VM. The guest's highlight set is server-side state only; nothing is sent back to the client, as in vanilla.


🔄 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/7608 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/recipe-book-seen` --- ### 📝 Commits (5) - [`db562ee`](https://github.com/horizon-rust/horizon/commit/db562ee212f33949784a8e09dda974fc97aed222) feat: read ServerboundRecipeBookSeenRecipePacket - [`00d0bf8`](https://github.com/horizon-rust/horizon/commit/00d0bf86aaac00a6826734a45d78102baab82036) test: the seen recipe is a two-byte display id - [`1f1e308`](https://github.com/horizon-rust/horizon/commit/1f1e308e0ab75cf9c2c311c19c35f1d6cbfe2828) feat: a guest's seen recipe clears its highlight - [`723afba`](https://github.com/horizon-rust/horizon/commit/723afbaabaaeff95b1b3c84da20debbc23764e8e) test: a display id names the recipe it was numbered for - [`c69a290`](https://github.com/horizon-rust/horizon/commit/c69a290bc34a3176cfaaca3e6f5795b628f909eb) port_map: handleRecipeBookSeenRecipePacket is ported ### 📊 Changes **5 files changed** (+116 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/advancements.rs` (+46 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+14 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+38 -1) 📝 `crates/horizon-protocol/src/packets/recipes.rs` (+17 -0) 📝 `tools/port_map/rest-018.tsv` (+1 -1) </details> ### 📄 Description `ServerGamePacketListenerImpl.handleRecipeBookSeenRecipePacket` asks the recipe manager for the display the client names — `getRecipeFromDisplay(recipe.recipe())` (bytecode 12–26) — and, when it finds it, hands the holder's id to `player.getRecipeBook().removeHighlight(...)` (31–45). `ServerRecipeBook.removeHighlight` is `this.highlight.remove(key)` (bytecode 0–11): the recipe stops being one the book announces as new. An id that names no display does nothing. **What Horizon lacked** Two pieces: 1. `horizon-protocol`'s serverbound play enum had no variant for opcode 48, so the packet read as `Serverbound::Unknown(48, ..)` and the hub's dispatch (which matches typed variants only) dropped it. 2. The hub therefore never cleared the guest's `toBeDisplayed` set, so a recipe the guest had already looked at kept its highlight on the next `RecipeBookAdd`. Now `packets::recipes::RecipeBookSeenRecipe` reads and writes the one VarInt, `ServerAdvancements::recipe_of_display` is the manager's lookup over the display numbers the server handed out, and the hub's dispatch clears the guest's highlight for the display it names. **Proven:** `packets::play::tests::a_seen_recipe_is_one_varint_display_id` — opcode 48 with `AC 02` decodes to display 300 and encodes back to the same two bytes; a one-byte payload is refused; and an id that still has no variant (51, `SEEN_ADVANCEMENTS`) decodes as `Unknown(51, ..)`, which is exactly what opcode 48 did before this change. `lan::advancements::tests::a_display_id_names_the_recipe_it_was_numbered_for` — with two fixture recipes the displays are numbered in id order, so display `0` is `minecraft:aaa_shaped`, display `1` is `minecraft:bbb_smelting`, and display `2` is `None`; the handler asks this and a `None` clears nothing. **Not proven:** the hub's arm itself has no test — a guest connection's inbox has no fixture in this crate, so what runs end to end (a bot sending opcode 48 and being sent a `RecipeBookAdd` without the highlight) is left to the VM. The guest's highlight set is server-side state only; nothing is sent back to the client, as in vanilla. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7712
No description provided.