[PR #2303] [MERGED] setblock and data keep a container's loot table #4186

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

📋 Pull Request Information

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

Base: main ← Head: fix/setblock-loot-table


📝 Commits (1)

  • fbbed63 setblock and data keep a container's loot table

📊 Changes

3 files changed (+85 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+76 -2)
📝 crates/horizon-client/src/game/commands/data.rs (+3 -1)
📝 tools/command_exec_corpus.py (+6 -0)

📄 Description

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

What and why

setblock … chest{LootTable:"…",LootTableSeed:42L} made an empty chest: the command's tag went through save::decode_block_entity, whose BlockEntity::Chest has nowhere to keep a loot table, so data get block showed Items: []. Vanilla keeps LootTable and LootTableSeed (RandomizableContainer.tryLoadLootTable) and saves them (trySaveLootTable) until the container is unpacked.

The fix follows what #2073 does for a loaded chunk. An empty container given a LootTable is rolled at once with that seed, and the roll is kept with its chunk (ChunkExtras::rolled_loot). While the items are still the roll, the container saves its table and seed, and data get now shows them (RolledLoot::restore). Once the items change, it saves and shows its items. data merge and data modify go through the same path, and a tag without a table drops the one the container had.

Testing

  • command_exec: new cases set a seeded simple_dungeon chest, then data get it whole and its LootTableSeed. The output matches the 26.3 oracle text for text (870/870). On main, data get printed Items: [] and no table.
  • In game, on the server thread and in-frame: data get shows LootTable and LootTableSeed: 42L, and opening the chest shows 18 stacks. They're the same stacks in the same slots as vanilla's own roll of that table and seed (the spawn_loot harness of #2285). After item replace … container.0, data get shows the items and no table. Saved, quit and reopened, the chest still has its table and the same 18 stacks.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at a42857ab4, 4 min 47 s)

Check Result
Scope ✅ 3 files, +85 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ⚠️ 2 macOS-only errors, fixed by #2299
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1335 passed
Parity command_exec ✅ here; 30 affected, to run in CI

🤖 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/2303 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/setblock-loot-table` --- ### 📝 Commits (1) - [`fbbed63`](https://github.com/horizon-rust/horizon/commit/fbbed63f04094038e076f127c5995b72f2b85d31) setblock and data keep a container's loot table ### 📊 Changes **3 files changed** (+85 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+76 -2) 📝 `crates/horizon-client/src/game/commands/data.rs` (+3 -1) 📝 `tools/command_exec_corpus.py` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why `setblock … chest{LootTable:"…",LootTableSeed:42L}` made an empty chest: the command's tag went through `save::decode_block_entity`, whose `BlockEntity::Chest` has nowhere to keep a loot table, so `data get block` showed `Items: []`. Vanilla keeps `LootTable` and `LootTableSeed` (`RandomizableContainer.tryLoadLootTable`) and saves them (`trySaveLootTable`) until the container is unpacked. The fix follows what #2073 does for a loaded chunk. An empty container given a `LootTable` is rolled at once with that seed, and the roll is kept with its chunk (`ChunkExtras::rolled_loot`). While the items are still the roll, the container saves its table and seed, and `data get` now shows them (`RolledLoot::restore`). Once the items change, it saves and shows its items. `data merge` and `data modify` go through the same path, and a tag without a table drops the one the container had. ## Testing - `command_exec`: new cases set a seeded `simple_dungeon` chest, then `data get` it whole and its `LootTableSeed`. The output matches the 26.3 oracle text for text (870/870). On main, `data get` printed `Items: []` and no table. - In game, on the server thread and in-frame: `data get` shows `LootTable` and `LootTableSeed: 42L`, and opening the chest shows 18 stacks. They're the same stacks in the same slots as vanilla's own roll of that table and seed (the `spawn_loot` harness of #2285). After `item replace … container.0`, `data get` shows the items and no table. Saved, quit and reopened, the chest still has its table and the same 18 stacks. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at a42857ab4, 4 min 47 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +85 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ⚠️ 2 macOS-only errors, fixed by #2299 | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1335 passed | | Parity | `command_exec` ✅ here; 30 affected, to run in CI | 🤖 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:15:19 +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#4186
No description provided.