[PR #6664] [MERGED] Native mods: a recipe ingredient of a mod's own kind #7020

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6664
Author: @Qwerner88880
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: hooks-ingredient-hook


📝 Commits (1)

  • df3a7ff Native mods: a recipe ingredient of a mod's own kind

📊 Changes

4 files changed (+88 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/crafting.rs (+49 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+24 -0)
📝 docs/native-mods.md (+9 -0)
➕ tools/native-hook-fragments/ingredient.json (+6 -0)

📄 Description

🤖 Opened by Qwerner88880's AI agent (ZCode, GLM-5.3), not by Qwerner88880 personally.

Part of #5367. Predicates over components need a match-time hook, not this load-time list, and follow separately.

What and why

An ingredient that names a type in a namespace outside minecraft: used to fail the recipe file whole. It now reaches native_ingredient(kind, data, items), a free function in crafting.rs which mixin bundles hook: fill the item list with what the ingredient matches, as a tag is. The list holds item ids only. Duplicates are removed keeping first-seen order. The hook is called once per ingredient by each copy that loads the recipes — the crafting tables', the network copy's — so at least twice per load, and the answer must be the same. An unclaimed kind leaves the list empty and the recipe fails, as an unknown kind does; a bare type name is minecraft:'s own.

The catalog target names horizon_client_lib, the package crafting.rs compiles into since #5446's split: horizon-mixins resolves the crate by its package and refuses horizon_client::crafting::…. The same split left menu's and breathing's catalog targets on the old crate name — a bundle on either hook by name fails today, tracked in #6662, not fixed here.

Live proof

A staged build of this branch (the catalog stamped on a copy, horizon-mixins apply at the pinned rev, a testmod bundle answering testmod:ore with [raw_copper, redstone, raw_copper] — the duplicate on purpose — and leaving testmod:none empty), with the hook's helper compiled in:

Case Result
the bundle applies status: ok, the staged native_ingredient calls the helper
the book requirements = HolderSet::Items([raw_copper, redstone]) — first-seen order, the duplicate gone
UpdateRecipes furnace_input and a stonecutting entry's input hold both
the crafting copy Recipes::load carries the recipe, its ingredient matches what the hook listed
an unclaimed kind testmod:none's recipe never reaches the network copy
the hook's trace 6 calls per full load: [none, ore, ore] from the network copy's load, the same three from the crafting copy's
two guests the lan_bot suite in the staged build: two protocol guests over TCP, each reading its own UpdateRecipes and RecipeBookAdd with the hook's items, both staying connected (18/18 in the suite)

Not proven

  • a craft in the game's window: craftability is proven at Recipes::load and the wire level, no GUI was opened.
  • no mod_api entry: #6253 is unmerged; its extension covers hooks that lack one once it lands.

Note for the reviewer

tools/pr_ready.py's Python suite has one failure on this Windows machine that is not from this PR: test_world_input_capture.test_capture_lifecycle panics (exit 101) on clean origin/main here too — the diff touches no Python. CI on Linux will show whether it fails there.

Self-check

tools/pr_ready.py on DESKTOP-H7P5E7K against origin/main at fd88a545d, 2 min 50 s:

Check Result
Scope ✅ 4 files, +88 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 1 error, pre-existing on clean main on this machine (see the note above)
rustfmt / clippy ✅ / ✅
tests: horizon-client, horizon-client-lib ✅ 1927 passed

🤖 Generated with ZCode AI agent (GLM-5.3)


🔄 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/6664 **Author:** [@Qwerner88880](https://github.com/Qwerner88880) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `hooks-ingredient-hook` --- ### 📝 Commits (1) - [`df3a7ff`](https://github.com/horizon-rust/horizon/commit/df3a7ffd7315a2b40af56b61de621a8c30fc8f4e) Native mods: a recipe ingredient of a mod's own kind ### 📊 Changes **4 files changed** (+88 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/crafting.rs` (+49 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+24 -0) 📝 `docs/native-mods.md` (+9 -0) ➕ `tools/native-hook-fragments/ingredient.json` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Qwerner88880's AI agent (ZCode, GLM-5.3), not by Qwerner88880 personally. Part of #5367. Predicates over components need a match-time hook, not this load-time list, and follow separately. ## What and why An ingredient that names a type in a namespace outside `minecraft:` used to fail the recipe file whole. It now reaches `native_ingredient(kind, data, items)`, a free function in `crafting.rs` which mixin bundles hook: fill the item list with what the ingredient matches, as a tag is. The list holds item ids only. Duplicates are removed keeping first-seen order. The hook is called once per ingredient by each copy that loads the recipes — the crafting tables', the network copy's — so at least twice per load, and the answer must be the same. An unclaimed kind leaves the list empty and the recipe fails, as an unknown kind does; a bare type name is `minecraft:`'s own. The catalog target names `horizon_client_lib`, the package `crafting.rs` compiles into since #5446's split: horizon-mixins resolves the crate by its package and refuses `horizon_client::crafting::…`. The same split left `menu`'s and `breathing`'s catalog targets on the old crate name — a bundle on either hook by name fails today, tracked in #6662, not fixed here. ## Live proof A staged build of this branch (the catalog stamped on a copy, `horizon-mixins apply` at the pinned rev, a `testmod` bundle answering `testmod:ore` with `[raw_copper, redstone, raw_copper]` — the duplicate on purpose — and leaving `testmod:none` empty), with the hook's helper compiled in: | Case | Result | | --- | --- | | the bundle applies | `status: ok`, the staged `native_ingredient` calls the helper | | the book | requirements = `HolderSet::Items([raw_copper, redstone])` — first-seen order, the duplicate gone | | `UpdateRecipes` | `furnace_input` and a stonecutting entry's input hold both | | the crafting copy | `Recipes::load` carries the recipe, its ingredient matches what the hook listed | | an unclaimed kind | `testmod:none`'s recipe never reaches the network copy | | the hook's trace | 6 calls per full load: `[none, ore, ore]` from the network copy's load, the same three from the crafting copy's | | two guests | the `lan_bot` suite in the staged build: two protocol guests over TCP, each reading its own `UpdateRecipes` and `RecipeBookAdd` with the hook's items, both staying connected (18/18 in the suite) | ## Not proven - a craft in the game's window: craftability is proven at `Recipes::load` and the wire level, no GUI was opened. - no `mod_api` entry: #6253 is unmerged; its extension covers hooks that lack one once it lands. ## Note for the reviewer `tools/pr_ready.py`'s Python suite has one failure **on this Windows machine that is not from this PR**: `test_world_input_capture.test_capture_lifecycle` panics (exit 101) on clean `origin/main` here too — the diff touches no Python. CI on Linux will show whether it fails there. ## Self-check `tools/pr_ready.py` on DESKTOP-H7P5E7K against `origin/main` at fd88a545d, 2 min 50 s: | Check | Result | | --- | --- | | Scope | ✅ 4 files, +88 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 1 error, pre-existing on clean `main` on this machine (see the note above) | | rustfmt / clippy | ✅ / ✅ | | tests: horizon-client, horizon-client-lib | ✅ 1927 passed | 🤖 Generated with ZCode AI agent (GLM-5.3) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:32:14 +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#7020
No description provided.