[PR #5910] [MERGED] Data packs and content mods: remove and replace recipes by filter #6555

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

📋 Pull Request Information

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

Base: main ← Head: recipe-filters


📝 Commits (1)

  • 56d304c Data packs and content mods: remove and replace recipes by filter

📊 Changes

11 files changed (+473 additions, -8 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/src/brewing.rs (+3 -1)
📝 crates/horizon-client-render/src/datapack.rs (+5 -3)
📝 crates/horizon-client/src/crafting.rs (+48 -1)
📝 crates/horizon-client/src/lan/recipes.rs (+3 -0)
📝 crates/horizon-client/src/recipe_book.rs (+3 -2)
📝 crates/horizon-client/src/stations.rs (+3 -1)
📝 crates/horizon-items/Cargo.toml (+1 -0)
📝 crates/horizon-items/src/lib.rs (+1 -0)
➕ crates/horizon-items/src/recipe_filters.rs (+374 -0)
📝 docs/native-mods.md (+31 -0)

📄 Description

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

Fixes #5583.

What and why

Data files data/<ns>/recipe_filter/<name>.json with {"filters": [...]}, readable from content mods and data packs, remove recipes or swap an item in them without replacing the recipe files.

  • Match keys, all must hold: id and type (glob, *), input (an item or #tag among the inputs), output (an item among the outputs, under result / results / output / outputs).
  • Exactly one action: remove: true, or replace_input / replace_output with {from, to}.
  • Filters run on each recipe's JSON after the packs merge and the load conditions are checked, so they cover mod recipe types too.
  • Every recipe loader applies them through one shared module (horizon_items::recipe_filters): crafting, stations, brewing, the recipe book, and the LAN recipe sync (property sets).
  • Files apply in id order; a pack's file replaces a same-id file.
  • A filter with an unknown key, or without exactly one action, is skipped with a warning, so a typo never matches all recipes.
  • Docs: a "Recipe filters" section in docs/native-mods.md, beside "Conditional data".
  • Cargo.lock: +1 line, only the log edge for horizon-items (log is already in the workspace).

Design notes:

  • The issue left the exact shape open, so this is a small first shape: glob, not regex. * covers the common cases (minecraft:*_planks, mymod:*). Regex can be added later as a new key without breaking existing files.
  • Coordination with #5367 (custom/fluid ingredient types, open): filters work on JSON strings, so a new ingredient type's item strings are matched and swapped too, as long as they are plain ids or {"tag": ...}.

Kind

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

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

Vanilla reference

Horizon-only: vanilla has no recipe filters. With no filter files nothing changes, so there is no parity harness.

Other projects' code

none

Tests

  • 5 unit tests in recipe_filters: glob; remove by id / type / items; swaps in a mod type and in tag objects; bad filters skipped; a pack replaces a mod's file; id order.
  • recipe_filters_remove_and_swap, through the real Recipes::load.
  • clippy -D warnings and rustfmt are clean.
  • In game (offscreen, vanilla furnaces, a world data pack): vanilla smelts raw iron to an iron ingot and cobblestone to stone. With {"id": "minecraft:iron_ingot_from_*", "remove": true} and {"type": "minecraft:smelting", "replace_output": {"from": "minecraft:stone", "to": "minecraft:dirt"}} plus /reload, the raw iron and its coal stay unburnt and cobblestone smelts to dirt. With the pack removed and /reload, vanilla again.

Self-check

pr_ready (tools/pr_ready.py --quick on boilingpoint, against origin/main at 9543d2a68, 10 min 17 s)

Check Result
Scope ✅ 11 files, +473 −8
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 515 passed (40 s)
rustfmt ✅ (11 s)
clippy ✅ (2 min 37 s)
tests: workspace ❌ 2694 passed, 1 failed (2 min 51 s)
doc tests ✅ 0 passed (6 s)
content root tests ✅ 21 passed (1 min 22 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (2 s)
launcher clippy ✅ (56 s)
launcher tests ✅ 362 passed (1 min 32 s)
Parity ➖ 365 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 353 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The one failing test is gfx::frame_gen::interpolation::tests::moves_the_view_halfway_with_the_camera (a float comparison, 0.28009704 against 0.28004465 and 0.2801672). This PR does not touch interpolation.rs, and I did not run the test on a clean origin/main, so I cannot say whether it also fails there.

🤖 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/5910 **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-filters` --- ### 📝 Commits (1) - [`56d304c`](https://github.com/horizon-rust/horizon/commit/56d304c7249f2dd63253a0b5e28f9ee3fd5f6cd0) Data packs and content mods: remove and replace recipes by filter ### 📊 Changes **11 files changed** (+473 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/src/brewing.rs` (+3 -1) 📝 `crates/horizon-client-render/src/datapack.rs` (+5 -3) 📝 `crates/horizon-client/src/crafting.rs` (+48 -1) 📝 `crates/horizon-client/src/lan/recipes.rs` (+3 -0) 📝 `crates/horizon-client/src/recipe_book.rs` (+3 -2) 📝 `crates/horizon-client/src/stations.rs` (+3 -1) 📝 `crates/horizon-items/Cargo.toml` (+1 -0) 📝 `crates/horizon-items/src/lib.rs` (+1 -0) ➕ `crates/horizon-items/src/recipe_filters.rs` (+374 -0) 📝 `docs/native-mods.md` (+31 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Sonnet 5.5), not by Sylviromi personally. Fixes #5583. ## What and why Data files `data/<ns>/recipe_filter/<name>.json` with `{"filters": [...]}`, readable from content mods and data packs, remove recipes or swap an item in them without replacing the recipe files. - Match keys, all must hold: `id` and `type` (glob, `*`), `input` (an item or `#tag` among the inputs), `output` (an item among the outputs, under `result` / `results` / `output` / `outputs`). - Exactly one action: `remove: true`, or `replace_input` / `replace_output` with `{from, to}`. - Filters run on each recipe's JSON after the packs merge and the load conditions are checked, so they cover mod recipe types too. - Every recipe loader applies them through one shared module (`horizon_items::recipe_filters`): crafting, stations, brewing, the recipe book, and the LAN recipe sync (property sets). - Files apply in id order; a pack's file replaces a same-id file. - A filter with an unknown key, or without exactly one action, is skipped with a warning, so a typo never matches all recipes. - Docs: a "Recipe filters" section in `docs/native-mods.md`, beside "Conditional data". - Cargo.lock: +1 line, only the `log` edge for `horizon-items` (`log` is already in the workspace). Design notes: - The issue left the exact shape open, so this is a small first shape: glob, not regex. `*` covers the common cases (`minecraft:*_planks`, `mymod:*`). Regex can be added later as a new key without breaking existing files. - Coordination with #5367 (custom/fluid ingredient types, open): filters work on JSON strings, so a new ingredient type's item strings are matched and swapped too, as long as they are plain ids or `{"tag": ...}`. ## Kind - [x] feature: something new for players (listed under New in the release notes) Label: feature (I cannot set labels on this repository; a maintainer please add it). ## Vanilla reference Horizon-only: vanilla has no recipe filters. With no filter files nothing changes, so there is no parity harness. ## Other projects' code none ## Tests - 5 unit tests in `recipe_filters`: glob; remove by id / type / items; swaps in a mod type and in tag objects; bad filters skipped; a pack replaces a mod's file; id order. - `recipe_filters_remove_and_swap`, through the real `Recipes::load`. - clippy `-D warnings` and rustfmt are clean. - In game (offscreen, vanilla furnaces, a world data pack): vanilla smelts raw iron to an iron ingot and cobblestone to stone. With `{"id": "minecraft:iron_ingot_from_*", "remove": true}` and `{"type": "minecraft:smelting", "replace_output": {"from": "minecraft:stone", "to": "minecraft:dirt"}}` plus `/reload`, the raw iron and its coal stay unburnt and cobblestone smelts to dirt. With the pack removed and `/reload`, vanilla again. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on boilingpoint, against origin/main at 9543d2a68, 10 min 17 s) | Check | Result | | --- | --- | | Scope | ✅ 11 files, +473 −8 | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 515 passed (40 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (2 min 37 s) | | tests: workspace | ❌ 2694 passed, 1 failed (2 min 51 s) | | doc tests | ✅ 0 passed (6 s) | | content root tests | ✅ 21 passed (1 min 22 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (2 s) | | launcher clippy | ✅ (56 s) | | launcher tests | ✅ 362 passed (1 min 32 s) | | Parity | ➖ 365 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 353 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The one failing test is `gfx::frame_gen::interpolation::tests::moves_the_view_halfway_with_the_camera` (a float comparison, `0.28009704 against 0.28004465 and 0.2801672`). This PR does not touch `interpolation.rs`, and I did not run the test on a clean `origin/main`, so I cannot say whether it also fails there. 🤖 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:22:53 +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#6555
No description provided.