[PR #5949] [MERGED] Native mods: send a server's recipes to its Horizon clients #6581

Closed
opened 2026-11-03 06:23:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5949
Author: @Sylviromi
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: recipe-sync


📝 Commits (8)

  • c79b897 Native mods: send a server's recipes to its Horizon clients
  • 08fd8f8 Native mods: the synced recipes reach the recipe book's list, and the mods hear of them once the player is there
  • 45480f7 Native mods: forget the recipe book's model through its own module
  • 34ba858 Recipe book: a namespaced recipe keeps its id
  • 0a0d056 Merge main into recipe-sync (both hooks kept beside native_data_pack_files)
  • 1dd14c4 Merge main into recipe-sync (server_data_loaded hook kept beside the recipe sync hooks)
  • 7268233 Native mods: a load that asks for no recipe types puts the clients back on their own; the type list counts against the last part's cap
  • cd6a6e1 Merge main into recipe-sync (the recipe filters run inside Recipes::sources)

📊 Changes

12 files changed (+425 additions, -26 deletions)

View changed files

📝 crates/horizon-client/src/crafting.rs (+36 -9)
📝 crates/horizon-client/src/game.rs (+4 -1)
📝 crates/horizon-client/src/game/extras.rs (+1 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+35 -4)
📝 crates/horizon-client/src/game/native_recipes.rs (+123 -8)
📝 crates/horizon-client/src/game/recipe_book.rs (+5 -0)
📝 crates/horizon-client/src/game/remote.rs (+5 -0)
📝 crates/horizon-client/src/lan/hub.rs (+21 -0)
📝 crates/horizon-client/src/lan/mod.rs (+1 -1)
📝 crates/horizon-client/src/lan/recipes.rs (+183 -0)
📝 crates/horizon-client/src/recipe_book.rs (+3 -3)
➕ tools/native-hook-fragments/recipe_sync.json (+8 -0)

📄 Description

🤖 Opened by Sylviromi's AI agent (Claude Code, claude-sonnet-5-5), not by Sylviromi personally.

Fixes #5929.

Label: feature (I cannot set labels on this repository; for a maintainer).

What and why

A recipe viewer or a content mod's client half cannot see a server's recipes: the client reads its own copy of the packs, so a world data pack's recipes, or a recipe added only on the server, never reach it. NeoForge covers this with OnDatapackSyncEvent.sendRecipes and RecipesReceivedEvent. This adds both.

  • Server hook native_datapack_sync(recipe_types: &mut Vec<String>) (OnDatapackSyncEvent.sendRecipes). Asked once per load, when the tables are built: world open and every /reload.
  • Sending. The server takes the final recipes of those types (Recipes::sources: packs merged, load conditions held) and sends them to Horizon clients only (brand horizon) on horizon:recipe_content, right after the vanilla UpdateRecipes at a join and at /reload. Payloads stay within the 1 MiB clientbound cap; the last one carries the type list. Vanilla clients get nothing new, and when no mod asks, nothing is sent.
  • Client. On the last part its Recipes become its own root recipes minus those types, plus the server's (Recipes::sources and Recipes::from_sources are the split of Recipes::load, so both sides build from one list). Game::recipes() reads that, and the recipe-book model and the native_recipes cache are made again. The client hook native_recipes_received(recipe_types) (RecipesReceivedEvent) fires once the window has its player, because a join's recipes arrive before the player does.
  • Bounds. A malformed or endless stream is cut off: at most 1,000,000 recipes, then it is dropped with a warning.
  • One fix it needed (34ba8585e). The recipe-book model and the native recipe list prefixed every crafting and cooking id with minecraft:, so a namespaced recipe (a content mod's, or a data pack's mymod:x) became minecraft:mymod:x. crafting::recipe_id now prefixes only bare vanilla names. This is a pre-existing bug that the sync made visible.
  • Hooks are declared in tools/native-hook-fragments/recipe_sync.json (both, with their NeoForge counterparts and side). API number: next, given at merge.

Related: #5910 (recipe filters) applies its filters inside the recipe source list, so once both merge the synced recipes are filtered too. Whichever merges second needs a small main merge in crafting.rs.

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

Horizon-only API, following NeoForge's OnDatapackSyncEvent / RecipesReceivedEvent (docs/native-hooks-neoforge.md). Vanilla's UpdateRecipes packet is unchanged and still sent first. Nothing changes for vanilla behaviour when no mod asks, so there is no parity harness.

Other projects' code

none

Tests and proof

  • Unit tests for the payload format (asked types only, ids made whole, the last part carries the types) and for splitting under the cap. Recipe, crafting and hook-catalog tests pass.
  • In game, offscreen single player with content mods. A test mod asks for minecraft:smelting and a content mod's machine recipe type. The window logs, each time recipes arrive, whether its own native_recipes and native_recipes_of_type see a world data pack's smelting recipe and machine recipe:
    • join, no pack: absent (1666 machine recipes)
    • pack added + /reload: both present (1667)
    • pack removed + /reload: absent again (1666)
  • The existing screen, inventory, recipe and machine-screen checks still pass.

Self-check

Run on the branch before origin/main moved (against 5bbecdc49). The clippy failure is needless_borrow at crates/horizon-world/src/block_state_properties.rs:161, a file this PR does not touch; origin/main has since fixed it. The branch has no conflicts with the newer origin/main in the files it changes.

pr_ready (tools/pr_ready.py --quick on boilingpoint, against origin/main at 5bbecdc49, 3 min 23 s)

Check Result
Scope ✅ 12 files, +352 −21
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (45 s)
rustfmt ✅ (9 s)
clippy ❌ failed (29 s)
tests: horizon-client ✅ 1680 passed (1 min 59 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

moves_the_view_halfway_with_the_camera did not fail in this run.

🤖 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/5949 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `recipe-sync` --- ### 📝 Commits (8) - [`c79b897`](https://github.com/horizon-rust/horizon/commit/c79b897210ce7551be87d6c0552e10dfe82a589f) Native mods: send a server's recipes to its Horizon clients - [`08fd8f8`](https://github.com/horizon-rust/horizon/commit/08fd8f8a1f05db5b8555976473be5605169278e3) Native mods: the synced recipes reach the recipe book's list, and the mods hear of them once the player is there - [`45480f7`](https://github.com/horizon-rust/horizon/commit/45480f7b1b3c1f6df9beb006d0445f00c56e9f05) Native mods: forget the recipe book's model through its own module - [`34ba858`](https://github.com/horizon-rust/horizon/commit/34ba8585ed55c3bec35845d202b28344c7f4d277) Recipe book: a namespaced recipe keeps its id - [`0a0d056`](https://github.com/horizon-rust/horizon/commit/0a0d056239671142e6c0bb6a7a30c081ed3232d9) Merge main into recipe-sync (both hooks kept beside native_data_pack_files) - [`1dd14c4`](https://github.com/horizon-rust/horizon/commit/1dd14c4cd21c7d17c09731288e9a8c4a28d9a213) Merge main into recipe-sync (server_data_loaded hook kept beside the recipe sync hooks) - [`7268233`](https://github.com/horizon-rust/horizon/commit/7268233fce482dccd72c6ca63a5440d45dbd2568) Native mods: a load that asks for no recipe types puts the clients back on their own; the type list counts against the last part's cap - [`cd6a6e1`](https://github.com/horizon-rust/horizon/commit/cd6a6e1c89baf3ba3b0738815d0f367e173f8cc6) Merge main into recipe-sync (the recipe filters run inside Recipes::sources) ### 📊 Changes **12 files changed** (+425 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/crafting.rs` (+36 -9) 📝 `crates/horizon-client/src/game.rs` (+4 -1) 📝 `crates/horizon-client/src/game/extras.rs` (+1 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+35 -4) 📝 `crates/horizon-client/src/game/native_recipes.rs` (+123 -8) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+5 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+21 -0) 📝 `crates/horizon-client/src/lan/mod.rs` (+1 -1) 📝 `crates/horizon-client/src/lan/recipes.rs` (+183 -0) 📝 `crates/horizon-client/src/recipe_book.rs` (+3 -3) ➕ `tools/native-hook-fragments/recipe_sync.json` (+8 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, claude-sonnet-5-5), not by Sylviromi personally. Fixes #5929. Label: feature (I cannot set labels on this repository; for a maintainer). ## What and why A recipe viewer or a content mod's client half cannot see a server's recipes: the client reads its own copy of the packs, so a world data pack's recipes, or a recipe added only on the server, never reach it. NeoForge covers this with `OnDatapackSyncEvent.sendRecipes` and `RecipesReceivedEvent`. This adds both. - **Server hook** `native_datapack_sync(recipe_types: &mut Vec<String>)` (`OnDatapackSyncEvent.sendRecipes`). Asked once per load, when the tables are built: world open and every `/reload`. - **Sending.** The server takes the final recipes of those types (`Recipes::sources`: packs merged, load conditions held) and sends them to Horizon clients only (brand `horizon`) on `horizon:recipe_content`, right after the vanilla `UpdateRecipes` at a join and at `/reload`. Payloads stay within the 1 MiB clientbound cap; the last one carries the type list. Vanilla clients get nothing new, and when no mod asks, nothing is sent. - **Client.** On the last part its `Recipes` become its own root recipes minus those types, plus the server's (`Recipes::sources` and `Recipes::from_sources` are the split of `Recipes::load`, so both sides build from one list). `Game::recipes()` reads that, and the recipe-book model and the `native_recipes` cache are made again. The client hook `native_recipes_received(recipe_types)` (`RecipesReceivedEvent`) fires once the window has its player, because a join's recipes arrive before the player does. - **Bounds.** A malformed or endless stream is cut off: at most 1,000,000 recipes, then it is dropped with a warning. - **One fix it needed** (`34ba8585e`). The recipe-book model and the native recipe list prefixed every crafting and cooking id with `minecraft:`, so a namespaced recipe (a content mod's, or a data pack's `mymod:x`) became `minecraft:mymod:x`. `crafting::recipe_id` now prefixes only bare vanilla names. This is a pre-existing bug that the sync made visible. - Hooks are declared in `tools/native-hook-fragments/recipe_sync.json` (both, with their NeoForge counterparts and side). API number: next, given at merge. Related: #5910 (recipe filters) applies its filters inside the recipe source list, so once both merge the synced recipes are filtered too. Whichever merges second needs a small main merge in `crafting.rs`. ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference Horizon-only API, following NeoForge's `OnDatapackSyncEvent` / `RecipesReceivedEvent` (`docs/native-hooks-neoforge.md`). Vanilla's `UpdateRecipes` packet is unchanged and still sent first. Nothing changes for vanilla behaviour when no mod asks, so there is no parity harness. ## Other projects' code none ## Tests and proof - Unit tests for the payload format (asked types only, ids made whole, the last part carries the types) and for splitting under the cap. Recipe, crafting and hook-catalog tests pass. - In game, offscreen single player with content mods. A test mod asks for `minecraft:smelting` and a content mod's machine recipe type. The window logs, each time recipes arrive, whether its own `native_recipes` and `native_recipes_of_type` see a world data pack's smelting recipe and machine recipe: - join, no pack: absent (1666 machine recipes) - pack added + `/reload`: both present (1667) - pack removed + `/reload`: absent again (1666) - The existing screen, inventory, recipe and machine-screen checks still pass. ## Self-check Run on the branch before `origin/main` moved (against `5bbecdc49`). The clippy failure is `needless_borrow` at `crates/horizon-world/src/block_state_properties.rs:161`, a file this PR does not touch; `origin/main` has since fixed it. The branch has no conflicts with the newer `origin/main` in the files it changes. **pr_ready** (`tools/pr_ready.py --quick` on boilingpoint, against origin/main at 5bbecdc49, 3 min 23 s) | Check | Result | | --- | --- | | Scope | ✅ 12 files, +352 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (45 s) | | rustfmt | ✅ (9 s) | | clippy | ❌ failed (29 s) | | tests: horizon-client | ✅ 1680 passed (1 min 59 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `moves_the_view_halfway_with_the_camera` did not fail in this run. 🤖 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 06:23:19 +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#6581
No description provided.