[PR #7408] [MERGED] Commands find content mods' loot tables #7585

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7408
Author: @k3yh
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/mod-loot-command-ids


📝 Commits (1)

  • a54a0a7 Commands find content mods' loot tables

📊 Changes

1 file changed (+50 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/chat.rs (+50 -1)

📄 Description

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

What and why

A content mod's loot tables work in its chests, but /loot can't name them:

/loot spawn ~ ~2 ~ loot dregora:dregorarl/loot/piratejunk_loot
Can't find element 'dregora:dregorarl/loot/piratejunk_loot' in registry 'minecraft:loot_table'

Vanilla's /loot ... loot <id> takes any loaded table, from every namespace. Horizon checks the id against the tables resource_ids lists from the resources root (chat.rs), and that list read only data/minecraft/loot_table. A mod's data/<ns>/loot_table never joined it. (Found while porting a dungeon mod; #3628 was the same gap for structures in /locate.)

Now the list holds the tables of every namespace under data/: those on the disk (the content root a mod adds to) and those in a prepared root's data file, as templates_under already does for structure templates.

Recipes aren't affected: /recipe takes a key and checks it against the recipe index, which has the mods' recipes.

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

Change

  • chat.rs: json_ids_of_every_namespace(root, kind) lists data/<ns>/<kind>/**.json for each namespace (disk and data file); ResourceIds::loot_tables uses it.
  • Test loot_tables_of_every_namespace_are_listed: a vanilla table and a mod's are both listed, a non-JSON file isn't.

Vanilla reference

LootCommand reads the table with ResourceOrIdArgument.lootTable, which resolves it in the server's reloadable LOOT_TABLE registry: every namespace of every loaded pack.

Other projects' code

none

Test

Single player and dedicated server, each before (nightly c9d474d) and after (this branch), with a content mod that ships loot tables (--dev-mod, and the .hmod in a server's horizon-mods):

Command Before After
loot spawn … loot dregora:dregorarl/loot/piratejunk_loot (the mod's) Can't find element Dropped 1 [Bone] (server: 1 [Glass Bottle])
loot spawn … loot minecraft:chests/simple_dungeon Dropped 6 items Dropped 6 items
loot spawn … loot dregora:no/such_table Can't find element Can't find element

Self-check

pr_ready (tools/pr_ready.py --quick --base 1b7df0564 on DESKTOP-S9O4938, 3 min 56 s):

Check Result
Scope ✅ 1 files, +50 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 612 run, FAILED (errors=1, skipped=1)
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 693 passed
doc tests ✅
mod API up to date ✅
Parity ➖ not run (--quick)

The Python failure is not in this change: test_port_ledger cannot import tests.test_class_index on this machine, as on main.

🤖 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/7408 **Author:** [@k3yh](https://github.com/k3yh) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mod-loot-command-ids` --- ### 📝 Commits (1) - [`a54a0a7`](https://github.com/horizon-rust/horizon/commit/a54a0a733d00bea39f59915576ece3850d768e7d) Commands find content mods' loot tables ### 📊 Changes **1 file changed** (+50 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/chat.rs` (+50 -1) </details> ### 📄 Description > 🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh personally. ## What and why A content mod's loot tables work in its chests, but `/loot` can't name them: ``` /loot spawn ~ ~2 ~ loot dregora:dregorarl/loot/piratejunk_loot Can't find element 'dregora:dregorarl/loot/piratejunk_loot' in registry 'minecraft:loot_table' ``` Vanilla's `/loot ... loot <id>` takes any loaded table, from every namespace. Horizon checks the id against the tables `resource_ids` lists from the resources root (`chat.rs`), and that list read only `data/minecraft/loot_table`. A mod's `data/<ns>/loot_table` never joined it. (Found while porting a dungeon mod; #3628 was the same gap for structures in `/locate`.) Now the list holds the tables of every namespace under `data/`: those on the disk (the content root a mod adds to) and those in a prepared root's data file, as `templates_under` already does for structure templates. Recipes aren't affected: `/recipe` takes a key and checks it against the recipe index, which has the mods' recipes. ## 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 ## Change - `chat.rs`: `json_ids_of_every_namespace(root, kind)` lists `data/<ns>/<kind>/**.json` for each namespace (disk and data file); `ResourceIds::loot_tables` uses it. - Test `loot_tables_of_every_namespace_are_listed`: a vanilla table and a mod's are both listed, a non-JSON file isn't. ## Vanilla reference `LootCommand` reads the table with `ResourceOrIdArgument.lootTable`, which resolves it in the server's reloadable `LOOT_TABLE` registry: every namespace of every loaded pack. ## Other projects' code none ## Test Single player and dedicated server, each before (nightly c9d474d) and after (this branch), with a content mod that ships loot tables (`--dev-mod`, and the `.hmod` in a server's `horizon-mods`): | Command | Before | After | | --- | --- | --- | | `loot spawn … loot dregora:dregorarl/loot/piratejunk_loot` (the mod's) | Can't find element | Dropped 1 [Bone] (server: 1 [Glass Bottle]) | | `loot spawn … loot minecraft:chests/simple_dungeon` | Dropped 6 items | Dropped 6 items | | `loot spawn … loot dregora:no/such_table` | Can't find element | Can't find element | ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base 1b7df0564` on DESKTOP-S9O4938, 3 min 56 s): | Check | Result | | --- | --- | | Scope | ✅ 1 files, +50 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 612 run, FAILED (errors=1, skipped=1) | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 693 passed | | doc tests | ✅ | | mod API up to date | ✅ | | Parity | ➖ not run (--quick) | The Python failure is not in this change: `test_port_ledger` cannot import `tests.test_class_index` on this machine, as on main. 🤖 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 07:20:18 +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#7585
No description provided.