[PR #5069] [MERGED] Experiments: the trade_rebalance flag applies its built-in data pack #6042

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5069
Author: @masa-masa-0314
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: feat/trade-rebalance


📝 Commits (10+)

  • a5d6d8a Biomes: the palette holds a world's biomes too
  • ce83c14 Commands: a world's packs complete and match their biomes and tags
  • 6ea12f7 Data packs: the world's chunks and the game read one biome table
  • 7eabfed Data packs: one pack list builds the biomes, the worldgen and the commands
  • ccb19c6 Biomes: the table survives world switches, and tags nest
  • 10fa933 Create World: the Experiments screen, the feature packs and dropped packs
  • 6975e9c Experiments: the More tab's button opens, and a world keeps its selection
  • 228b7d3 Fix packed_biomes call after merging main; restore world_worldgen_overrides's doc comment
  • 072cc61 Create World: the preparing screen and the experimental-features warning
  • 5acff38 Create World: the world's enabled features persist in level.dat

📊 Changes

42 files changed (+1656 additions, -198 deletions)

View changed files

📝 crates/horizon-client-render/src/chunk.rs (+1 -1)
📝 crates/horizon-client-render/src/datapack.rs (+177 -13)
📝 crates/horizon-client/examples/probe/trading_fixture.rs (+1 -1)
📝 crates/horizon-client/src/game.rs (+119 -6)
📝 crates/horizon-client/src/game/advancements.rs (+1 -0)
📝 crates/horizon-client/src/game/commands.rs (+24 -7)
📝 crates/horizon-client/src/game/commands/execute.rs (+12 -24)
📝 crates/horizon-client/src/game/commands/terrain_cmds.rs (+8 -8)
📝 crates/horizon-client/src/game/creatures.rs (+2 -2)
📝 crates/horizon-client/src/game/dedicated.rs (+1 -1)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+1 -1)
📝 crates/horizon-client/src/game/fishing.rs (+1 -1)
📝 crates/horizon-client/src/game/functions.rs (+81 -31)
📝 crates/horizon-client/src/game/initial_spawn.rs (+1 -1)
📝 crates/horizon-client/src/game/integrated.rs (+13 -0)
📝 crates/horizon-client/src/game/lan.rs (+29 -18)
📝 crates/horizon-client/src/game/levels.rs (+1 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+235 -5)
📝 crates/horizon-client/src/game/moving_pistons.rs (+1 -1)
📝 crates/horizon-client/src/game/music.rs (+1 -1)

...and 22 more files

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode/GLM), not by masa-masa-0314 personally.

What and why

A world with the trade_rebalance feature flag now actually plays the flag's built-in data pack: the overridden villager trade tags and trades (armorer/librarian experiments), the librarian's biome enchantment books, and the changed chest loot. Until now the flag only existed as a name: datapack::enabled_ids never force-enabled the feature pack from the world's flags, the trade registries were loaded without any pack overlay, and the librarian trades' #minecraft:trades/<biome_common> enchantment pools could not resolve.

What changed:

  • datapack::enabled_ids takes the world's enabled_features and reproduces MinecraftServer.configurePackRepository: a feature pack whose requested features the world enables is force-enabled (enableForcedFeaturePacks), a selected pack asking for missing features is dropped. The world's flags thread through pack_stack/content_overlay, the worldgen overrides, packed_biomes, level_shapes and the integrated open path (the world-data preload reads them from the world's level.dat).
  • Trades::load(root, overlay) merges the packs' villager_trade/trade_set files (top pack replaces, SimpleJsonResourceReloadListener) and their tags (entries join in pack order, replace clears — TagLoader.load), and StationData passes the world's overlay through.
  • Enchantments::load_with(root, overlay) merges the packs' enchantment tags, so the pack's #minecraft:trades/desert_common etc. resolve for the librarian book trades.
  • PackOverlay::tag_kind fix: it stripped a leading : that is not part of the documented tags/<ns>:<registry>/<path> key shape, so it never matched anything and every data pack's tag overlay silently no-opped (loot tags included). With the fix, user packs' tag overlays work as documented.
  • /loot give ... loot <table> fix: when the table had a random_sequence, the roll used self.res.items() — the resource root without any packs — instead of the world's tables; the sequence branch now rolls the world's own tables.
  • Fixes the stacked world-save commit (088731f31) leaving integrated.rs calling packed_biomes without its resources argument — the horizon-client bin did not compile on that branch.

Stacked on #5004 (feat/minecart-improvements), which carries the whole flag chain (#4577→#5004).

Vanilla reference

  • MinecraftServer.configurePackRepository + enableForcedFeaturePacks (decompiled from the 26.3 jar): the flag → feature-pack force-enable and the missing-features drop.
  • The built-in pack data/minecraft/datapacks/trade_rebalance (10 trade tags with "replace": true, 81 trade files, 6 chest loot tables) and redstone_experiments (empty — code-gated only, out of scope here).
  • TagLoader.load and SimpleJsonResourceReloadListener for the merge semantics.

Self-check

**pr_ready** (`tools/pr_ready.py --base upstream/main`)

| Check | Result |
| --- | --- |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| rustfmt | ✅ |
| clippy | ✅ |
| tests: horizon-client, horizon-client-render, horizon-items, horizon-world | ✅ 2388 passed |
| doc tests | ✅ |
| content root tests | ✅ 6 passed |

Notes:

  • pr_ready's Python suite reports test_report_without_a_load_average (Windows cmd /C ver output decoding on this machine's codepage) and a flaky dedicated_server run; the perf-bench failure reproduces identically on a pristine checkout of the branch's base and touches no code this PR changes.
  • The scope line counts the whole six-PR stack against upstream/main; this PR's own diff is 15 files, +182/−37.
  • Verified headlessly on this machine with a flag world: /datapack list shows trade_rebalance (feature) among the enabled packs, and /loot give @s loot minecraft:chests/desert_pyramid rolls the pack's table (saddles drop, leather does not). The trades side is covered by the same Trades/overlay path the game loads (StationData → merchant::Session).

Screenshots

No UI change; the machine's offscreen renderer is blank (project known issue), so the behavioral evidence above is command-based.


🔄 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/5069 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/trade-rebalance` --- ### 📝 Commits (10+) - [`a5d6d8a`](https://github.com/horizon-rust/horizon/commit/a5d6d8af2aed8c015e85fa976f58ac9ee212a8bd) Biomes: the palette holds a world's biomes too - [`ce83c14`](https://github.com/horizon-rust/horizon/commit/ce83c14926968888e8386c8481150de5be7307ae) Commands: a world's packs complete and match their biomes and tags - [`6ea12f7`](https://github.com/horizon-rust/horizon/commit/6ea12f710f6a76c68eef7077da5b1bc8d81b57aa) Data packs: the world's chunks and the game read one biome table - [`7eabfed`](https://github.com/horizon-rust/horizon/commit/7eabfedc8d9aa1c49f6dac9b2d3696124c4fb6ed) Data packs: one pack list builds the biomes, the worldgen and the commands - [`ccb19c6`](https://github.com/horizon-rust/horizon/commit/ccb19c6cfeddf003f15ce5d1b793413e6eed8347) Biomes: the table survives world switches, and tags nest - [`10fa933`](https://github.com/horizon-rust/horizon/commit/10fa933647dd3f97d0fbb9e8a227986cc95207bf) Create World: the Experiments screen, the feature packs and dropped packs - [`6975e9c`](https://github.com/horizon-rust/horizon/commit/6975e9c9e1ce92d3377f40b1e601d2e5a5940eb2) Experiments: the More tab's button opens, and a world keeps its selection - [`228b7d3`](https://github.com/horizon-rust/horizon/commit/228b7d349179711fd45264f34a472fe5cdfccfb2) Fix packed_biomes call after merging main; restore world_worldgen_overrides's doc comment - [`072cc61`](https://github.com/horizon-rust/horizon/commit/072cc61277ffc2c52877fd246cdedfe7e3b9a921) Create World: the preparing screen and the experimental-features warning - [`5acff38`](https://github.com/horizon-rust/horizon/commit/5acff3836c1d778b9bd25e4a8afd461377608990) Create World: the world's enabled features persist in level.dat ### 📊 Changes **42 files changed** (+1656 additions, -198 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chunk.rs` (+1 -1) 📝 `crates/horizon-client-render/src/datapack.rs` (+177 -13) 📝 `crates/horizon-client/examples/probe/trading_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+119 -6) 📝 `crates/horizon-client/src/game/advancements.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+24 -7) 📝 `crates/horizon-client/src/game/commands/execute.rs` (+12 -24) 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+8 -8) 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -2) 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -1) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/game/fishing.rs` (+1 -1) 📝 `crates/horizon-client/src/game/functions.rs` (+81 -31) 📝 `crates/horizon-client/src/game/initial_spawn.rs` (+1 -1) 📝 `crates/horizon-client/src/game/integrated.rs` (+13 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+29 -18) 📝 `crates/horizon-client/src/game/levels.rs` (+1 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+235 -5) 📝 `crates/horizon-client/src/game/moving_pistons.rs` (+1 -1) 📝 `crates/horizon-client/src/game/music.rs` (+1 -1) _...and 22 more files_ </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode/GLM), not by masa-masa-0314 personally. ## What and why A world with the **`trade_rebalance`** feature flag now actually plays the flag's built-in data pack: the overridden villager trade tags and trades (armorer/librarian experiments), the librarian's biome enchantment books, and the changed chest loot. Until now the flag only existed as a name: `datapack::enabled_ids` never force-enabled the feature pack from the world's flags, the trade registries were loaded without any pack overlay, and the librarian trades' `#minecraft:trades/<biome_common>` enchantment pools could not resolve. What changed: - **`datapack::enabled_ids` takes the world's `enabled_features`** and reproduces `MinecraftServer.configurePackRepository`: a feature pack whose requested features the world enables is force-enabled (`enableForcedFeaturePacks`), a selected pack asking for missing features is dropped. The world's flags thread through `pack_stack`/`content_overlay`, the worldgen overrides, `packed_biomes`, `level_shapes` and the integrated open path (the world-data preload reads them from the world's `level.dat`). - **`Trades::load(root, overlay)`** merges the packs' `villager_trade`/`trade_set` files (top pack replaces, `SimpleJsonResourceReloadListener`) and their tags (entries join in pack order, `replace` clears — `TagLoader.load`), and `StationData` passes the world's overlay through. - **`Enchantments::load_with(root, overlay)`** merges the packs' enchantment tags, so the pack's `#minecraft:trades/desert_common` etc. resolve for the librarian book trades. - **`PackOverlay::tag_kind` fix**: it stripped a leading `:` that is not part of the documented `tags/<ns>:<registry>/<path>` key shape, so it never matched anything and *every* data pack's tag overlay silently no-opped (loot tags included). With the fix, user packs' tag overlays work as documented. - **`/loot give ... loot <table>` fix**: when the table had a `random_sequence`, the roll used `self.res.items()` — the resource root without any packs — instead of the world's tables; the sequence branch now rolls the world's own tables. - Fixes the stacked world-save commit (`088731f31`) leaving `integrated.rs` calling `packed_biomes` without its `resources` argument — the `horizon-client` bin did not compile on that branch. Stacked on #5004 (`feat/minecart-improvements`), which carries the whole flag chain (#4577→#5004). ## Vanilla reference - `MinecraftServer.configurePackRepository` + `enableForcedFeaturePacks` (decompiled from the 26.3 jar): the flag → feature-pack force-enable and the missing-features drop. - The built-in pack `data/minecraft/datapacks/trade_rebalance` (10 trade tags with `"replace": true`, 81 trade files, 6 chest loot tables) and `redstone_experiments` (empty — code-gated only, out of scope here). - `TagLoader.load` and `SimpleJsonResourceReloadListener` for the merge semantics. ## Self-check ``` **pr_ready** (`tools/pr_ready.py --base upstream/main`) | Check | Result | | --- | --- | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-render, horizon-items, horizon-world | ✅ 2388 passed | | doc tests | ✅ | | content root tests | ✅ 6 passed | ``` Notes: - `pr_ready`'s Python suite reports `test_report_without_a_load_average` (Windows `cmd /C ver` output decoding on this machine's codepage) and a flaky `dedicated_server` run; the perf-bench failure reproduces identically on a pristine checkout of the branch's base and touches no code this PR changes. - The scope line counts the whole six-PR stack against `upstream/main`; this PR's own diff is 15 files, +182/−37. - Verified headlessly on this machine with a flag world: `/datapack list` shows `trade_rebalance (feature)` among the enabled packs, and `/loot give @s loot minecraft:chests/desert_pyramid` rolls the pack's table (saddles drop, leather does not). The trades side is covered by the same `Trades`/overlay path the game loads (`StationData` → `merchant::Session`). ## Screenshots No UI change; the machine's offscreen renderer is blank (project known issue), so the behavioral evidence above is command-based. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:49 +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#6042
No description provided.