[PR #5126] [MERGED] Recipe results: a bare item id names the item, as vanilla reads it #6092

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5126
Author: @Akirabane
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/4904-recipe-result-string


📝 Commits (1)

  • 57c54aa Recipe results: a bare item id names the item, as vanilla reads it

📊 Changes

7 files changed (+158 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/crafting.rs (+33 -5)
📝 crates/horizon-client/src/lan/advancements.rs (+3 -1)
📝 crates/horizon-client/src/lan/recipes.rs (+3 -1)
📝 crates/horizon-client/src/mod_content_tests.rs (+76 -0)
📝 crates/horizon-client/src/recipe_book.rs (+1 -1)
📝 crates/horizon-client/src/stations.rs (+3 -3)
📝 crates/horizon-world/src/loot.rs (+39 -1)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code) and Akirabane himself, after his review.

What and why

A recipe's result can be written as a bare item id in vanilla 26.3: ItemStackTemplate.CODEC (and TransmuteResult.CODEC) is Codec.withAlternative(<id, count, components>, Item.CODEC), so "result": "mod:item" makes that item. Horizon read only result.id, so a recipe written that way loaded and made minecraft:air. The same loader reads a world's data packs, so they were affected as much as content mods.

horizon_world::loot::recipe_result_id now reads both forms, and every place that reads a recipe's result uses it: crafting and cooking recipes (through Template::parse), banner duplicate and shield decoration, smithing and stonecutting, the recipe book, the stonecutter and advancement packets, and the smelting loot modifier.

Fixes #4904. The report doesn't include the recipe file, so this is the divergence I could reproduce that gives exactly its symptom (a mod recipe whose result is minecraft:air): before the change, a content mod's "result": "ruby:ruby" made air, with {"id": "ruby:ruby"} it made the item.

Not in this PR: a result object with no id (such as the item key of older versions) still loads here as an empty stack, while vanilla refuses the recipe. That is a separate change.

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

Read with javap on the pinned 26.3 server jar:

  • net.minecraft.world.item.ItemStackTemplate: MAP_CODEC has a required id and optional count (1 to 99) and components; CODEC is Codec.withAlternative(MAP_CODEC.codec(), Item.CODEC, ...).
  • net.minecraft.world.item.crafting.TransmuteResult.CODEC: the same alternative, with id optional in the object form.
  • The recipes that read result with ItemStackTemplate.CODEC: ShapedRecipe, ShapelessRecipe, AbstractCookingRecipe, SingleItemRecipe, SmithingTransformRecipe and the special crafting recipes.

Harness: the recipe harness compares only vanilla's own recipe files, so it doesn't reach the bare form and is not extended in this PR. Tests added instead: the helper (loot::recipe_result_tests), Recipes::load with a bare result (crafting::tests), and the full content root test mod_content::tests::mod_recipe_results_are_an_item_stack_or_a_bare_item_id (a content mod's recipes, with an object, a bare id, a bare block item and a count).

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-6PU1HU6, against origin/main at 36f4bc00d, 6 min 7 s)

Check Result
Scope ✅ 7 files, +158 −12
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 495 run, FAILED (errors=1, skipped=12) (47 s)
rustfmt ✅ (7 s)
clippy ✅ (12 s)
tests: horizon-client, horizon-world ✅ 1656 passed (3 min 34 s)
doc tests ✅ 0 passed (2 s)
content root tests ✅ 7 passed (1 min 22 s)
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)

The one failing check, "Python tests", is test_port_ledger failing to import tests.test_class_index on my machine: a package named tests in my global Python site-packages shadows the repository's tests/ folder. It fails the same way on an untouched checkout, this PR touches no Python file, and the test passes with python -S.


🔄 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/5126 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/4904-recipe-result-string` --- ### 📝 Commits (1) - [`57c54aa`](https://github.com/horizon-rust/horizon/commit/57c54aac903b8bf3a84ff0bd0ea38c41db97bba3) Recipe results: a bare item id names the item, as vanilla reads it ### 📊 Changes **7 files changed** (+158 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/crafting.rs` (+33 -5) 📝 `crates/horizon-client/src/lan/advancements.rs` (+3 -1) 📝 `crates/horizon-client/src/lan/recipes.rs` (+3 -1) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+76 -0) 📝 `crates/horizon-client/src/recipe_book.rs` (+1 -1) 📝 `crates/horizon-client/src/stations.rs` (+3 -3) 📝 `crates/horizon-world/src/loot.rs` (+39 -1) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code) and Akirabane himself, after his review. ## What and why A recipe's `result` can be written as a bare item id in vanilla 26.3: `ItemStackTemplate.CODEC` (and `TransmuteResult.CODEC`) is `Codec.withAlternative(<id, count, components>, Item.CODEC)`, so `"result": "mod:item"` makes that item. Horizon read only `result.id`, so a recipe written that way loaded and made `minecraft:air`. The same loader reads a world's data packs, so they were affected as much as content mods. `horizon_world::loot::recipe_result_id` now reads both forms, and every place that reads a recipe's result uses it: crafting and cooking recipes (through `Template::parse`), banner duplicate and shield decoration, smithing and stonecutting, the recipe book, the stonecutter and advancement packets, and the smelting loot modifier. Fixes #4904. The report doesn't include the recipe file, so this is the divergence I could reproduce that gives exactly its symptom (a mod recipe whose result is `minecraft:air`): before the change, a content mod's `"result": "ruby:ruby"` made air, with `{"id": "ruby:ruby"}` it made the item. Not in this PR: a result object with no `id` (such as the `item` key of older versions) still loads here as an empty stack, while vanilla refuses the recipe. That is a separate change. ## Kind - [x] 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 Read with `javap` on the pinned 26.3 server jar: - `net.minecraft.world.item.ItemStackTemplate`: `MAP_CODEC` has a required `id` and optional `count` (1 to 99) and `components`; `CODEC` is `Codec.withAlternative(MAP_CODEC.codec(), Item.CODEC, ...)`. - `net.minecraft.world.item.crafting.TransmuteResult.CODEC`: the same alternative, with `id` optional in the object form. - The recipes that read `result` with `ItemStackTemplate.CODEC`: `ShapedRecipe`, `ShapelessRecipe`, `AbstractCookingRecipe`, `SingleItemRecipe`, `SmithingTransformRecipe` and the special crafting recipes. Harness: the `recipe` harness compares only vanilla's own recipe files, so it doesn't reach the bare form and is not extended in this PR. Tests added instead: the helper (`loot::recipe_result_tests`), `Recipes::load` with a bare result (`crafting::tests`), and the full content root test `mod_content::tests::mod_recipe_results_are_an_item_stack_or_a_bare_item_id` (a content mod's recipes, with an object, a bare id, a bare block item and a count). ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-6PU1HU6, against origin/main at 36f4bc00d, 6 min 7 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +158 −12 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 495 run, FAILED (errors=1, skipped=12) (47 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (12 s) | | tests: horizon-client, horizon-world | ✅ 1656 passed (3 min 34 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ✅ 7 passed (1 min 22 s) | | 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) | The one failing check, "Python tests", is `test_port_ledger` failing to import `tests.test_class_index` on my machine: a package named `tests` in my global Python `site-packages` shadows the repository's `tests/` folder. It fails the same way on an untouched checkout, this PR touches no Python file, and the test passes with `python -S`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:11:35 +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#6092
No description provided.