[PR #3739] [MERGED] Content mods: items patch their template's data components #5183

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3739
Author: @UMCEKO
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: mods/item-components


📝 Commits (1)

  • 5c66b27 Content mods: items patch their template's data components

📊 Changes

5 files changed (+206 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/mod_content.rs (+51 -4)
📝 crates/horizon-client/src/mod_content_tests.rs (+49 -1)
📝 crates/horizon-mods/src/content.rs (+83 -1)
📝 docs/modpacks.md (+2 -1)
📝 docs/mods.md (+21 -0)

📄 Description

🤖 Opened by UMCEKO's AI agent (Claude Code), not by UMCEKO.

Stack, part 1 of 7. The PRs come from a fork, so each one targets main and contains the ones before it. Please merge them in order; this PR's own change is its last commit.

→ 1. #3739
2. #3740
3. #3741
4. #3742
5. #3743
6. #3744
7. #3745

What and why

Item 3 of #3305. A content mod's item copied its template's components with only max_stack_size and rarity changeable, so a modded sword was stuck with its template's damage and durability. An item file may now carry components, a 26.3 data component patch over the template's entry: minecraft:<type> sets one, !minecraft:<type> with {} removes it.

{ "template": "minecraft:iron_sword",
  "components": { "minecraft:max_damage": 900, "!minecraft:repairable": {},
    "minecraft:attribute_modifiers": [{ "type": "minecraft:attack_damage", "id": "minecraft:base_attack_damage",
      "amount": 7.0, "operation": "add_value", "slot": "mainhand" }] } }
  • horizon-mods refuses non-vanilla component types, removals whose value isn't {}, and the two keys the file already has fields for.
  • The overlay (mod_content.rs) refuses a component type that no vanilla item has, so a typo fails the load instead of doing nothing.
  • Nothing changes without a content mod that uses it.

Items 1 and 2 of #3305 are left alone. Item 1 (smithing ingredients as {"item": ...}) is 1.21.1's format, which vanilla 26.3 refuses; horizon-port-pack already upgrades it (carry::ingredient), and #3384 touches that code. Item 2 (behaviour tied to vanilla ids) needs an item-to-class table, a design question for you.

Vanilla reference

DataComponentPatch's codec: !-prefixed keys remove a component, and each value is decoded by the component type's own codec, which is the shape items.json already holds. Tests: content_root_loads_with_every_table now adds a sword with its own durability and damage and checks what Items::load makes of it; new unit tests cover the patch and the refusals.

Self-check

pr_ready (tools/pr_ready.py --quick on nixos, against origin/main at b13b4f2c7, 6 min 42 s)

Check Result
Scope ✅ 5 files, +206 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 416 passed (26 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 9 s)
tests: horizon-client, horizon-mods ✅ 910 passed (1 min 54 s)
doc tests ✅ 0 passed (31 s)
content root tests ✅ 5 passed (1 min 9 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (2 s)
launcher clippy ✅ (34 s)
launcher tests ✅ 268 passed (53 s)
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)

Screenshots

None for this PR alone: it's the format. The tooltips and worn armour come later in the stack (#3742, #3744).

Tools used

  • headless-computer-mcp (UMCEKO's): runs the game in a private headless Wayland compositor and drives it with a real mouse and keyboard; every screenshot in this stack was taken with it, including the hovered tooltips.
  • tools/neoforge_oracle.py: the real mod jar on NeoForge 21.1.259, the ground truth (extended in this stack to export item components).
  • horizon-port-pack carry with --resources, then tools/mod_port_harness.py with examples/mod_port_probe.rs (extended in this stack to compare item stats and worn armour).
  • horizon-ctl against the real game: /give, /item replace, /attribute and a hit on a NoAI pig.
  • tools/pr_ready.py --quick, run against the PR before this one so the block covers this PR alone.

The test mod is Simplest Emerald Gear 1.0.6 for NeoForge 1.21.1 (MIT): 9 items, no dependencies. Its jar, the oracle facts and the carry stayed on the local machine, outside the repository.

🤖 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/3739 **Author:** [@UMCEKO](https://github.com/UMCEKO) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mods/item-components` --- ### 📝 Commits (1) - [`5c66b27`](https://github.com/horizon-rust/horizon/commit/5c66b27c9a8f4e98496b51c7b8f8d44e71b24f54) Content mods: items patch their template's data components ### 📊 Changes **5 files changed** (+206 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mod_content.rs` (+51 -4) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+49 -1) 📝 `crates/horizon-mods/src/content.rs` (+83 -1) 📝 `docs/modpacks.md` (+2 -1) 📝 `docs/mods.md` (+21 -0) </details> ### 📄 Description > 🤖 Opened by UMCEKO's AI agent (Claude Code), not by UMCEKO. **Stack, part 1 of 7.** The PRs come from a fork, so each one targets `main` and contains the ones before it. Please merge them in order; this PR's own change is its last commit. **→** 1. #3739 2. #3740 3. #3741 4. #3742 5. #3743 6. #3744 7. #3745 ## What and why Item 3 of #3305. A content mod's item copied its template's components with only `max_stack_size` and `rarity` changeable, so a modded sword was stuck with its template's damage and durability. An item file may now carry `components`, a 26.3 data component patch over the template's entry: `minecraft:<type>` sets one, `!minecraft:<type>` with `{}` removes it. ```json { "template": "minecraft:iron_sword", "components": { "minecraft:max_damage": 900, "!minecraft:repairable": {}, "minecraft:attribute_modifiers": [{ "type": "minecraft:attack_damage", "id": "minecraft:base_attack_damage", "amount": 7.0, "operation": "add_value", "slot": "mainhand" }] } } ``` - `horizon-mods` refuses non-vanilla component types, removals whose value isn't `{}`, and the two keys the file already has fields for. - The overlay (`mod_content.rs`) refuses a component type that no vanilla item has, so a typo fails the load instead of doing nothing. - Nothing changes without a content mod that uses it. Items 1 and 2 of #3305 are left alone. Item 1 (smithing ingredients as `{"item": ...}`) is 1.21.1's format, which vanilla 26.3 refuses; `horizon-port-pack` already upgrades it (`carry::ingredient`), and #3384 touches that code. Item 2 (behaviour tied to vanilla ids) needs an item-to-class table, a design question for you. ## Vanilla reference `DataComponentPatch`'s codec: `!`-prefixed keys remove a component, and each value is decoded by the component type's own codec, which is the shape `items.json` already holds. Tests: `content_root_loads_with_every_table` now adds a sword with its own durability and damage and checks what `Items::load` makes of it; new unit tests cover the patch and the refusals. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on nixos, against origin/main at b13b4f2c7, 6 min 42 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +206 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 416 passed (26 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 9 s) | | tests: horizon-client, horizon-mods | ✅ 910 passed (1 min 54 s) | | doc tests | ✅ 0 passed (31 s) | | content root tests | ✅ 5 passed (1 min 9 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (2 s) | | launcher clippy | ✅ (34 s) | | launcher tests | ✅ 268 passed (53 s) | | 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) | ## Screenshots None for this PR alone: it's the format. The tooltips and worn armour come later in the stack (#3742, #3744). ## Tools used - [headless-computer-mcp](https://github.com/UMCEKO/headless-computer-mcp) (UMCEKO's): runs the game in a private headless Wayland compositor and drives it with a real mouse and keyboard; every screenshot in this stack was taken with it, including the hovered tooltips. - `tools/neoforge_oracle.py`: the real mod jar on NeoForge 21.1.259, the ground truth (extended in this stack to export item components). - `horizon-port-pack carry` with `--resources`, then `tools/mod_port_harness.py` with `examples/mod_port_probe.rs` (extended in this stack to compare item stats and worn armour). - `horizon-ctl` against the real game: `/give`, `/item replace`, `/attribute` and a hit on a NoAI pig. - `tools/pr_ready.py --quick`, run against the PR before this one so the block covers this PR alone. The test mod is [Simplest Emerald Gear](https://modrinth.com/mod/simplest-emerald-gear) 1.0.6 for NeoForge 1.21.1 (MIT): 9 items, no dependencies. Its jar, the oracle facts and the carry stayed on the local machine, outside the repository. 🤖 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:10:48 +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#5183
No description provided.