[PR #7499] [MERGED] Native mods: a mod's own ingredient kind matching at craft time #7630

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

📋 Pull Request Information

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

Base: main ← Head: ingredient-test


📝 Commits (2)

  • 30e8337 Native mods: a mod's own ingredient kind matching at craft time
  • b56ec10 Merge main into #7499

📊 Changes

14 files changed (+240 additions, -36 deletions)

View changed files

📝 crates/horizon-client/examples/mod_port_probe.rs (+4 -4)
📝 crates/horizon-client/src/crafting.rs (+148 -22)
📝 crates/horizon-client/src/entry.rs (+9 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+1 -1)
📝 crates/horizon-client/src/game/native_recipes.rs (+2 -1)
📝 crates/horizon-client/src/lan/recipes.rs (+5 -1)
📝 crates/horizon-client/src/menu.rs (+1 -0)
📝 crates/horizon-client/src/menu/place.rs (+5 -3)
📝 crates/horizon-client/src/mod_api/generated.rs (+35 -0)
📝 crates/horizon-client/src/native_client_hooks.rs (+12 -0)
📝 crates/horizon-client/src/recipe_book.rs (+1 -1)
📝 crates/horizon-client/src/stations.rs (+3 -3)
📝 docs/native-mods.md (+8 -0)
➕ tools/native-hook-fragments/ingredient_test.json (+6 -0)

📄 Description

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

Part of #5367. The load-time half is #6664; this is matching at craft time.

What and why

The load-time hook only names items. Matching a concrete stack — its components, usually — is native_ingredient_test(kind, data, stack, accept): the ingredient's test calls it with the kind and JSON the load-time hook saw, the stack being matched and the verdict, already true (the list named the item). Set accept to false to refuse the stack (ICustomIngredient.test). The hook may be called many times a craft; the answer must be the same for the same stack.

Ingredient carries what matching needs now: the kind and its JSON for a mod's own kind, and NeoForge's shapes' parsed children — matching a stack asks each child its own way (any for compound, all for intersection, base-but-not-subtracted for difference), a mod's kind among them answering through its hook, as on NeoForge. The flat item list the book and the network copy see is unchanged. The furnace index holds every recipe an item names now, not just the first: a refused stack falls through to the next recipe whose test takes it.

Live proof

A staged build of this branch (the catalog stamped on a copy, horizon-mixins apply at the pinned revision, a testmod bundle whose load hook names minecraft:raw_copper for testmod:ore and testmod:unhandled, whose test hook refuses a damaged stack for testmod:ore only, both traced to a file):

Case Result
a whole stack matches: the shaped recipe takes it
a damaged stack, the kind directly refused by the hook
a damaged stack inside neoforge:compound refused — the shape's children are each asked their own test
a damaged stack, a kind no test hook vetoes accepted — the default verdict is true
the furnace, a whole stack ore_smelting (the hook's recipe)
the furnace, a damaged stack plain_smelting — a refused stack falls through to the next recipe naming the same item
the trace the hook consulted for both kinds; the unhandled one kept the default

Not proven

  • a craft in the game's window: the test harness hosts the hub without the game, and a guest's craft runs in the game's lan_crafting, so no bot drove a real craft; single-player was not run. The staged tests above drive the real Recipes::load, find_with and cook with the mixin's hook compiled in.
  • the book's placement (menu/place.rs) still matches by item name only: as vanilla's does — the final say is test at craft time.

Self-check

tools/pr_ready.py on DESKTOP-H7P5E7K against origin/main at b09827e93, 4 min 52 s:

Check Result
Scope ✅ 14 files, +240 −36
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed
rustfmt / clippy ✅ / ✅
tests: horizon-client, horizon-client-lib ✅ 2154 passed
doc tests ✅
mod API up to date ✅

🤖 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/7499 **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:** `ingredient-test` --- ### 📝 Commits (2) - [`30e8337`](https://github.com/horizon-rust/horizon/commit/30e83372d98aa8aabcacc10cf7faff87f74fd403) Native mods: a mod's own ingredient kind matching at craft time - [`b56ec10`](https://github.com/horizon-rust/horizon/commit/b56ec105e0c4893dd1b8d2d63665642133f067ea) Merge main into #7499 ### 📊 Changes **14 files changed** (+240 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/mod_port_probe.rs` (+4 -4) 📝 `crates/horizon-client/src/crafting.rs` (+148 -22) 📝 `crates/horizon-client/src/entry.rs` (+9 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+1 -1) 📝 `crates/horizon-client/src/game/native_recipes.rs` (+2 -1) 📝 `crates/horizon-client/src/lan/recipes.rs` (+5 -1) 📝 `crates/horizon-client/src/menu.rs` (+1 -0) 📝 `crates/horizon-client/src/menu/place.rs` (+5 -3) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+35 -0) 📝 `crates/horizon-client/src/native_client_hooks.rs` (+12 -0) 📝 `crates/horizon-client/src/recipe_book.rs` (+1 -1) 📝 `crates/horizon-client/src/stations.rs` (+3 -3) 📝 `docs/native-mods.md` (+8 -0) ➕ `tools/native-hook-fragments/ingredient_test.json` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Qwerner88880's AI agent (ZCode, GLM-5.3), not by Qwerner88880 personally. Part of #5367. The load-time half is #6664; this is matching at craft time. ## What and why The load-time hook only names items. Matching a concrete stack — its components, usually — is `native_ingredient_test(kind, data, stack, accept)`: the ingredient's `test` calls it with the kind and JSON the load-time hook saw, the stack being matched and the verdict, already `true` (the list named the item). Set `accept` to `false` to refuse the stack (`ICustomIngredient.test`). The hook may be called many times a craft; the answer must be the same for the same stack. `Ingredient` carries what matching needs now: the kind and its JSON for a mod's own kind, and NeoForge's shapes' parsed children — matching a stack asks each child its own way (any for compound, all for intersection, base-but-not-subtracted for difference), a mod's kind among them answering through its hook, as on NeoForge. The flat item list the book and the network copy see is unchanged. The furnace index holds every recipe an item names now, not just the first: a refused stack falls through to the next recipe whose test takes it. ## Live proof A staged build of this branch (the catalog stamped on a copy, `horizon-mixins apply` at the pinned revision, a `testmod` bundle whose load hook names `minecraft:raw_copper` for `testmod:ore` and `testmod:unhandled`, whose test hook refuses a damaged stack for `testmod:ore` only, both traced to a file): | Case | Result | | --- | --- | | a whole stack | matches: the shaped recipe takes it | | a damaged stack, the kind directly | refused by the hook | | a damaged stack inside `neoforge:compound` | refused — the shape's children are each asked their own `test` | | a damaged stack, a kind no test hook vetoes | accepted — the default verdict is `true` | | the furnace, a whole stack | `ore_smelting` (the hook's recipe) | | the furnace, a damaged stack | `plain_smelting` — a refused stack falls through to the next recipe naming the same item | | the trace | the hook consulted for both kinds; the unhandled one kept the default | ## Not proven - a craft in the game's window: the test harness hosts the hub without the game, and a guest's craft runs in the game's `lan_crafting`, so no bot drove a real craft; single-player was not run. The staged tests above drive the real `Recipes::load`, `find_with` and `cook` with the mixin's hook compiled in. - the book's placement (`menu/place.rs`) still matches by item name only: as vanilla's does — the final say is `test` at craft time. ## Self-check `tools/pr_ready.py` on DESKTOP-H7P5E7K against `origin/main` at b09827e93, 4 min 52 s: | Check | Result | | --- | --- | | Scope | ✅ 14 files, +240 −36 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed | | rustfmt / clippy | ✅ / ✅ | | tests: horizon-client, horizon-client-lib | ✅ 2154 passed | | doc tests | ✅ | | mod API up to date | ✅ | 🤖 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 07:21:06 +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#7630
No description provided.