[PR #523] [MERGED] Content mods (API 0.2): .hmod assets/ and data/, blocks and items from vanilla templates #2621

Closed
opened 2026-11-02 15:57:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/523
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: feat/mod-content


📝 Commits (1)

  • 746c888 horizon-mods: content mods (API 0.2), blocks and items declared from vanilla templates

📊 Changes

8 files changed (+711 additions, -38 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-mods/Cargo.toml (+1 -0)
➕ crates/horizon-mods/src/content.rs (+557 -0)
📝 crates/horizon-mods/src/lib.rs (+2 -0)
📝 crates/horizon-mods/src/manifest.rs (+80 -30)
📝 crates/horizon-mods/src/runtime.rs (+15 -7)
📝 crates/horizon-mods/tests/sandbox.rs (+33 -1)
📝 docs/mods.md (+22 -0)

📄 Description

First step of registries 0.2 from the modpacks design (#518). It reads and checks a content .hmod, the game doesn't use the content yet, and nothing changes for players with no mods.

What

  • Manifest:
    • api = "0.2" is accepted next to 0.1.
    • New capability registries ("add blocks and items to your worlds"); it requires API 0.2.
    • Code still links WIT horizon:mods@0.1.
  • Package:
    • mod.wasm is optional for a content-only mod, which must declare registries.
    • New Package::write_files writes assets/ and data/ into a .hmod, for tests and later for horizon-port-pack.
  • horizon_mods::content::Content reads a zip or folder mod's content and fences it:
    • plain resource paths only, so nothing like .., upper case, backslashes or absolute paths;
    • at most 65,536 files, 16 MiB each, 512 MiB in all;
    • files in the mod's own namespace only, plus additions to vanilla tags. Vanilla assets and vanilla data other than tags are refused.
  • Declarations live in data/<id>/horizon/block/*.json and data/<id>/horizon/item/*.json.
    • A block copies a vanilla template ("template": "minecraft:iron_block") and can override hardness, explosion resistance, light, requires_tool, friction, map colour, and sounds (taken from another vanilla block). By default it also adds a block item.
    • An item copies a vanilla template item and can override max_stack_size and rarity.
    • Unknown keys and out-of-range values are refused, and so is an item id that clashes with a block item.
  • Runtime:
    • Mods::load refuses an enabled mod whose content fails these checks and shows the reason on its row.
    • A content-only mod is on with no engine and no hooks, so is_running() stays false.
  • docs/mods.md: a "Content mods (API 0.2)" section.

Why

Content-tier mods are 68 of ATM10's 495 (#518) and the base for every other tier. The rest of the stack:

  • #530: the content root. Template rows are appended to every block table.
  • #531: the game loads content mods: loot, recipes, models, names and icons, with the ruby-content example verified in game.
  • #532: horizon-port-pack import and inventory (classified Create+'s 155 files).
  • #533: horizon-port-pack carry: a jar's data and assets as a content mod.

This branch was rebased on main after #518 merged.

How tested

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -j6 -- -D warnings: clean.
  • cargo test -p horizon-mods: 8 unit tests and 7 sandbox tests pass.
    • New tests: a zip and a folder content mod round-trip; every fence rule; the capability and API rules; path rules; Mods::load with a content-only mod (Running, no hooks) next to a refused one.
  • Parity is pending. tools/parity.py --changed origin/main selects all 309 harnesses (Cargo.lock and a client dependency changed). The game's behaviour doesn't change without mods, so I'll run it once on the integration commit with the overlay PR and paste the result here.

Needs Ludovic

Nothing yet.

🤖 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/523 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/mod-content` --- ### 📝 Commits (1) - [`746c888`](https://github.com/horizon-rust/horizon/commit/746c888cd3b85bfe27dbc15b292f0c62054300f6) horizon-mods: content mods (API 0.2), blocks and items declared from vanilla templates ### 📊 Changes **8 files changed** (+711 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-mods/Cargo.toml` (+1 -0) ➕ `crates/horizon-mods/src/content.rs` (+557 -0) 📝 `crates/horizon-mods/src/lib.rs` (+2 -0) 📝 `crates/horizon-mods/src/manifest.rs` (+80 -30) 📝 `crates/horizon-mods/src/runtime.rs` (+15 -7) 📝 `crates/horizon-mods/tests/sandbox.rs` (+33 -1) 📝 `docs/mods.md` (+22 -0) </details> ### 📄 Description First step of registries 0.2 from the modpacks design (#518). It reads and checks a content `.hmod`, the game doesn't use the content yet, and nothing changes for players with no mods. ## What - **Manifest:** - `api = "0.2"` is accepted next to `0.1`. - New capability `registries` ("add blocks and items to your worlds"); it requires API 0.2. - Code still links WIT `horizon:mods@0.1`. - **`Package`:** - `mod.wasm` is optional for a content-only mod, which must declare `registries`. - New `Package::write_files` writes `assets/` and `data/` into a `.hmod`, for tests and later for `horizon-port-pack`. - **`horizon_mods::content::Content`** reads a zip or folder mod's content and fences it: - plain resource paths only, so nothing like `..`, upper case, backslashes or absolute paths; - at most 65,536 files, 16 MiB each, 512 MiB in all; - files in the mod's own namespace only, plus additions to vanilla tags. Vanilla assets and vanilla data other than tags are refused. - **Declarations** live in `data/<id>/horizon/block/*.json` and `data/<id>/horizon/item/*.json`. - A block copies a vanilla template (`"template": "minecraft:iron_block"`) and can override hardness, explosion resistance, light, requires_tool, friction, map colour, and sounds (taken from another vanilla block). By default it also adds a block item. - An item copies a vanilla template item and can override `max_stack_size` and `rarity`. - Unknown keys and out-of-range values are refused, and so is an item id that clashes with a block item. - **Runtime:** - `Mods::load` refuses an enabled mod whose content fails these checks and shows the reason on its row. - A content-only mod is on with no engine and no hooks, so `is_running()` stays false. - `docs/mods.md`: a "Content mods (API 0.2)" section. ## Why Content-tier mods are 68 of ATM10's 495 (#518) and the base for every other tier. The rest of the stack: - #530: the content root. Template rows are appended to every block table. - #531: the game loads content mods: loot, recipes, models, names and icons, with the `ruby-content` example verified in game. - #532: `horizon-port-pack` import and inventory (classified Create+'s 155 files). - #533: `horizon-port-pack carry`: a jar's data and assets as a content mod. This branch was rebased on main after #518 merged. ## How tested - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -j6 -- -D warnings`: clean. - `cargo test -p horizon-mods`: 8 unit tests and 7 sandbox tests pass. - New tests: a zip and a folder content mod round-trip; every fence rule; the capability and API rules; path rules; `Mods::load` with a content-only mod (Running, no hooks) next to a refused one. - **Parity is pending.** `tools/parity.py --changed origin/main` selects all 309 harnesses (Cargo.lock and a client dependency changed). The game's behaviour doesn't change without mods, so I'll run it once on the integration commit with the overlay PR and paste the result here. ## Needs Ludovic Nothing yet. 🤖 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-02 15:57:43 +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#2621
No description provided.