[PR #4838] [MERGED] Native mods: recipes of a mod's own types (API next) #5884

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4838
Author: @Qwerner88880
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: hooks-recipes


📝 Commits (2)

  • d951767 Native mods: recipes of a mod's own types (API 23)
  • 836ea22 Merge hr/main; renumber recipe helpers to API 36; guard outside a world, read bare ids, test loading

📊 Changes

3 files changed (+203 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/crafting.rs (+135 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+62 -1)
📝 docs/native-mods.md (+6 -0)

📄 Description

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

What and why

Fixes #4809. Part of #3911 (Mods), gap R of #1854. A mod's machine (a crusher, a mixer, an altar) can now have recipes in files of its own type. Today Recipes::load reads such a file and drops it, because no branch knows its type.

  • Recipes::custom: a recipe whose type has a namespace other than minecraft stays loaded as its JSON, by type, in file order. It comes from data/<namespace>/recipe/*.json of the mods and the world's data packs, through the same loader, so a pack's file overrides by id and /reload reads it again. The game doesn't craft these or show them in the recipe book, and they aren't sent to clients.
  • native_recipes_of_type(kind): each recipe's id and JSON, for the mod to read as it likes. This stands in for a RecipeSerializer registry: nothing needs declaring, since the type's owner is the only reader.
  • native_recipe_ingredient(json): an item, a #tag or a list, through the existing Ingredient::parse, with test(stack).
  • native_recipe_result(json): id, count and components, through the existing Template::parse; none for an unknown item.

A minecraft: type the game doesn't know is still dropped, as now. These are helpers with no new hook points. NATIVE_HOOKS_API goes to the next free number: 23 in the code on this base, and it moves with whatever merges first. An "API 23" paragraph is in docs/native-mods.md.

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

Horizon-only: vanilla has no recipes outside its own types without a mod loader. Vanilla's RecipeManager logs a file that doesn't parse and goes on, and that stays as it is. Nothing changes for minecraft: recipes. CI's parity job picks the harnesses that cover crafting.rs. I didn't run parity here (no vanilla data on this machine).

Tests

Unit tests in crafting.rs: which types count as custom, and what recipe_result accepts.

In the game: a throwaway horizon-mixins bundle (not in this pull request) added a command that calls each helper. A data pack, on a dedicated server (--dedicated --nogui, Windows) with two real clients, under horizon-ctl --offscreen; all 20 checks passed:

Pack contents Result
Two recipes of proofpack:crusher both read, each with its own energy field
"input": "minecraft:iron_ore" the ingredient fits iron ore, not an oak log
"input": "#minecraft:logs" the tag expands: it fits an oak log, not dirt
{"id": ..., "count": 2}, and no count the stack, with count 2, then 1
A result naming an unknown item none
A type nobody uses, and minecraft:crafting_shapeless empty: vanilla's types aren't in this table
A file that doesn't parse logged and skipped
An ordinary recipe in the same pack still loads as a recipe
A new file and a removed file, then /reload the table follows
The pack disabled, then /reload the type is empty

Both clients stayed connected, with no errors. Not tested: a content mod's own data/<id>/recipe/ (only a data pack; it's the same loop), a real machine mod, and a pack with many thousands of such recipes.

Right after /datapack disable, before a /reload, the recipes are still there, and so is a vanilla-type recipe of that pack. That happens outside this change, so I left it.

Self-check

tools/pr_ready.py --quick --base origin/main on Windows. horizon-client doesn't currently build on Windows on main, because #4732 added unsafe to save.rs under #![forbid(unsafe_code)], so I ran this and the game with that one line relaxed locally. It isn't in this pull request, and the table counts it.

pr_ready (tools/pr_ready.py --quick on DESKTOP-H7P5E7K, against origin/main at 2a009ad16, 3 min 21 s)

Check Result
Scope ✅ 4 files, +98 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (1 min 6 s)
rustfmt ✅ (7 s)
clippy ✅ (47 s)
tests: horizon-client ✅ 1231 passed (1 min 16 s)
doc tests ✅ 0 passed (1 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)

🤖 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/4838 **Author:** [@Qwerner88880](https://github.com/Qwerner88880) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `hooks-recipes` --- ### 📝 Commits (2) - [`d951767`](https://github.com/horizon-rust/horizon/commit/d9517672efb27d78e7813607e4c19bb6255188ac) Native mods: recipes of a mod's own types (API 23) - [`836ea22`](https://github.com/horizon-rust/horizon/commit/836ea22364ff98fb1e71bac333ecc7967c8313d9) Merge hr/main; renumber recipe helpers to API 36; guard outside a world, read bare ids, test loading ### 📊 Changes **3 files changed** (+203 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/crafting.rs` (+135 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+62 -1) 📝 `docs/native-mods.md` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Qwerner88880's AI agent (Claude Code, Claude Opus 5.5), not by Qwerner88880 personally. ## What and why Fixes #4809. Part of #3911 (Mods), gap **R** of #1854. A mod's machine (a crusher, a mixer, an altar) can now have recipes in files of its own type. Today `Recipes::load` reads such a file and drops it, because no branch knows its `type`. - **`Recipes::custom`:** a recipe whose `type` has a namespace other than `minecraft` stays loaded as its JSON, by type, in file order. It comes from `data/<namespace>/recipe/*.json` of the mods and the world's data packs, through the same loader, so a pack's file overrides by id and `/reload` reads it again. The game doesn't craft these or show them in the recipe book, and they aren't sent to clients. - **`native_recipes_of_type(kind)`:** each recipe's id and JSON, for the mod to read as it likes. This stands in for a `RecipeSerializer` registry: nothing needs declaring, since the type's owner is the only reader. - **`native_recipe_ingredient(json)`:** an item, a `#tag` or a list, through the existing `Ingredient::parse`, with `test(stack)`. - **`native_recipe_result(json)`:** `id`, `count` and `components`, through the existing `Template::parse`; none for an unknown item. A `minecraft:` type the game doesn't know is still dropped, as now. These are helpers with no new hook points. `NATIVE_HOOKS_API` goes to the next free number: 23 in the code on this base, and it moves with whatever merges first. An "API 23" paragraph is in `docs/native-mods.md`. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] 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 Horizon-only: vanilla has no recipes outside its own types without a mod loader. Vanilla's `RecipeManager` logs a file that doesn't parse and goes on, and that stays as it is. Nothing changes for `minecraft:` recipes. CI's parity job picks the harnesses that cover `crafting.rs`. I didn't run parity here (no vanilla data on this machine). ## Tests **Unit tests** in `crafting.rs`: which types count as custom, and what `recipe_result` accepts. **In the game:** a throwaway horizon-mixins bundle (not in this pull request) added a command that calls each helper. A data pack, on a dedicated server (`--dedicated --nogui`, Windows) with two real clients, under `horizon-ctl --offscreen`; all 20 checks passed: | Pack contents | Result | | --- | --- | | Two recipes of `proofpack:crusher` | both read, each with its own `energy` field | | `"input": "minecraft:iron_ore"` | the ingredient fits iron ore, not an oak log | | `"input": "#minecraft:logs"` | the tag expands: it fits an oak log, not dirt | | `{"id": ..., "count": 2}`, and no count | the stack, with count 2, then 1 | | A result naming an unknown item | none | | A type nobody uses, and `minecraft:crafting_shapeless` | empty: vanilla's types aren't in this table | | A file that doesn't parse | logged and skipped | | An ordinary recipe in the same pack | still loads as a recipe | | A new file and a removed file, then `/reload` | the table follows | | The pack disabled, then `/reload` | the type is empty | Both clients stayed connected, with no errors. **Not tested:** a content mod's own `data/<id>/recipe/` (only a data pack; it's the same loop), a real machine mod, and a pack with many thousands of such recipes. Right after `/datapack disable`, before a `/reload`, the recipes are still there, and so is a vanilla-type recipe of that pack. That happens outside this change, so I left it. ## Self-check `tools/pr_ready.py --quick --base origin/main` on Windows. `horizon-client` doesn't currently build on Windows on main, because #4732 added `unsafe` to `save.rs` under `#![forbid(unsafe_code)]`, so I ran this and the game with that one line relaxed locally. It isn't in this pull request, and the table counts it. **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-H7P5E7K, against origin/main at 2a009ad16, 3 min 21 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +98 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (1 min 6 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (47 s) | | tests: horizon-client | ✅ 1231 passed (1 min 16 s) | | doc tests | ✅ 0 passed (1 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) | 🤖 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:15:40 +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#5884
No description provided.