[PR #1859] [MERGED] cargo horizon-mod: content mods (new --template content, build packs assets and data, check takes no code) #3823

Closed
opened 2026-11-03 04:12:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/mod-tool-content


📝 Commits (1)

  • ba4cf45 cargo horizon-mod: content mods (new --template content, build packs assets and data, check takes no code)

📊 Changes

15 files changed (+233 additions, -33 deletions)

View changed files

📝 crates/cargo-horizon-mod/src/check.rs (+13 -3)
📝 crates/cargo-horizon-mod/src/main.rs (+147 -21)
➕ crates/cargo-horizon-mod/template/content/block.json (+4 -0)
➕ crates/cargo-horizon-mod/template/content/blockstate.json (+5 -0)
➕ crates/cargo-horizon-mod/template/content/horizon-mod.toml (+10 -0)
➕ crates/cargo-horizon-mod/template/content/item.json (+3 -0)
➕ crates/cargo-horizon-mod/template/content/lang.json (+3 -0)
➕ crates/cargo-horizon-mod/template/content/loot.json (+11 -0)
➕ crates/cargo-horizon-mod/template/content/model.json (+4 -0)
➕ crates/cargo-horizon-mod/template/content/pickaxe.json (+3 -0)
➕ crates/cargo-horizon-mod/template/content/recipe.json (+6 -0)
📝 docs/api/mods.md (+2 -1)
📝 docs/mods.md (+6 -2)
📝 website/docs/content-mods.md (+15 -5)
📝 website/docs/make-a-mod.md (+1 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #1810 (the Make a mod guide); review that one first. This PR's own diff is the last commit.

What

Content mods could be made by hand but not built, checked or published with the tool. The guide in #1810 had to say so. Now they can:

  • cargo horizon-mod new my-blocks --template content makes a content mod: one block (Glowing Amethyst, copying vanilla's amethyst block, light 7) with its block state, model (vanilla's amethyst texture, so the template has no PNG), item model, name, loot table, a shapeless recipe and the pickaxe tag. --template code (the default) is the existing Rust template; an unknown template is an error.
  • cargo horizon-mod build packs the mod's assets/ and data/ into the .hmod beside the component. It used to pack only the manifest and mod.wasm. The files are read through horizon_mods::Content::read, which applies the game's checks (namespaces, paths, limits, block and item files), so a mistake fails the build, not the player's game. A folder with no Cargo.toml is a content mod: no compiler. Without registries in its capabilities, that is an error ("only a content mod … has no code").
  • cargo horizon-mod check takes a .hmod with no mod.wasm. Its trial run refused one ("the .hmod has no mod.wasm"), so the registry could not take content mods. index::inspect already reads their content as the game does; the report now says no code: content only, nothing to run, and the JSON has "code": false.
  • Docs: the guide's Content mods page (Start one, then build and check instead of zip), Make a mod (--template content), docs/mods.md, and the Mod API's tool row and ways in (a "Data only" row).

How tested

  • cargo test -p cargo-horizon-mod: a new test makes a content mod from the template, builds it with no Cargo.toml, reads the .hmod back (no wasm, 8 content files), checks it (code: false, the content-only line), and refuses an unknown template and a no-code mod without registries. The existing template test still passes.
  • ruby-content (the SDK example) built in a copy with the new build and checked: 4,051 bytes, may add blocks and items to your worlds, no code: content only.
  • In the game: a --template content mod built, then the game started offscreen with --dev-mod on it (isolated HORIZON_HOME, launcher home and XDG folders): the log says content from 1 mod(s); /setblock … gems:glowing_amethyst placed it beside a vanilla amethyst block and both draw the same texture; /give gave [Glowing Amethyst], named from the lang file, drawn in the hand and the hotbar.
  • node build.mjs (31 pages, link check clean), node --test src/ 20/20.
**pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at bd591f985, so #1810's diff included, 2 min 41 s)
| rustfmt ✅ | clippy ✅ | tests: cargo-horizon-mod ✅ 3 passed | Public tree ✅ | Parity ➖ no harness affected

Label skip-release: cargo horizon-mod is installed from git by modders, not shipped in a release.

🤖 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/1859 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/mod-tool-content` --- ### 📝 Commits (1) - [`ba4cf45`](https://github.com/horizon-rust/horizon/commit/ba4cf45aacb5564ae04bce109e466c48dea9f2eb) cargo horizon-mod: content mods (new --template content, build packs assets and data, check takes no code) ### 📊 Changes **15 files changed** (+233 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/cargo-horizon-mod/src/check.rs` (+13 -3) 📝 `crates/cargo-horizon-mod/src/main.rs` (+147 -21) ➕ `crates/cargo-horizon-mod/template/content/block.json` (+4 -0) ➕ `crates/cargo-horizon-mod/template/content/blockstate.json` (+5 -0) ➕ `crates/cargo-horizon-mod/template/content/horizon-mod.toml` (+10 -0) ➕ `crates/cargo-horizon-mod/template/content/item.json` (+3 -0) ➕ `crates/cargo-horizon-mod/template/content/lang.json` (+3 -0) ➕ `crates/cargo-horizon-mod/template/content/loot.json` (+11 -0) ➕ `crates/cargo-horizon-mod/template/content/model.json` (+4 -0) ➕ `crates/cargo-horizon-mod/template/content/pickaxe.json` (+3 -0) ➕ `crates/cargo-horizon-mod/template/content/recipe.json` (+6 -0) 📝 `docs/api/mods.md` (+2 -1) 📝 `docs/mods.md` (+6 -2) 📝 `website/docs/content-mods.md` (+15 -5) 📝 `website/docs/make-a-mod.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1810 (the Make a mod guide); review that one first. This PR's own diff is the last commit. ## What Content mods could be made by hand but not built, checked or published with the tool. The guide in #1810 had to say so. Now they can: - **`cargo horizon-mod new my-blocks --template content`** makes a content mod: one block (Glowing Amethyst, copying vanilla's amethyst block, light 7) with its block state, model (vanilla's amethyst texture, so the template has no PNG), item model, name, loot table, a shapeless recipe and the pickaxe tag. `--template code` (the default) is the existing Rust template; an unknown template is an error. - **`cargo horizon-mod build`** packs the mod's `assets/` and `data/` into the `.hmod` beside the component. It used to pack only the manifest and `mod.wasm`. The files are read through `horizon_mods::Content::read`, which applies the game's checks (namespaces, paths, limits, block and item files), so a mistake fails the build, not the player's game. A folder with no `Cargo.toml` is a content mod: no compiler. Without `registries` in its capabilities, that is an error ("only a content mod … has no code"). - **`cargo horizon-mod check`** takes a `.hmod` with no `mod.wasm`. Its trial run refused one ("the .hmod has no mod.wasm"), so the registry could not take content mods. `index::inspect` already reads their content as the game does; the report now says `no code: content only, nothing to run`, and the JSON has `"code": false`. - Docs: the guide's Content mods page (Start one, then build and check instead of zip), Make a mod (`--template content`), docs/mods.md, and the Mod API's tool row and ways in (a "Data only" row). ## How tested - `cargo test -p cargo-horizon-mod`: a new test makes a content mod from the template, builds it with no `Cargo.toml`, reads the `.hmod` back (no wasm, 8 content files), checks it (`code: false`, the content-only line), and refuses an unknown template and a no-code mod without `registries`. The existing template test still passes. - `ruby-content` (the SDK example) built in a copy with the new `build` and checked: 4,051 bytes, `may add blocks and items to your worlds`, `no code: content only`. - **In the game**: a `--template content` mod built, then the game started offscreen with `--dev-mod` on it (isolated `HORIZON_HOME`, launcher home and XDG folders): the log says `content from 1 mod(s)`; `/setblock … gems:glowing_amethyst` placed it beside a vanilla amethyst block and both draw the same texture; `/give` gave `[Glowing Amethyst]`, named from the lang file, drawn in the hand and the hotbar. - `node build.mjs` (31 pages, link check clean), `node --test src/` 20/20. ``` **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at bd591f985, so #1810's diff included, 2 min 41 s) | rustfmt ✅ | clippy ✅ | tests: cargo-horizon-mod ✅ 3 passed | Public tree ✅ | Parity ➖ no harness affected ``` Label `skip-release`: `cargo horizon-mod` is installed from git by modders, not shipped in a release. 🤖 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 04:12:34 +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#3823
No description provided.