[PR #1911] [MERGED] Structure chests keep the enchantments their loot rolled #3857

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

📋 Pull Request Information

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

Base: main ← Head: fix/structure-chest-enchantments


📝 Commits (1)

  • 89d6e1c Structure chests keep the enchantments their loot rolled

📊 Changes

1 file changed (+44 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/structure_blocks.rs (+44 -9)

📄 Description

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

What and why

Fixes #1437. Fixes #1910 (a desert temple chest's enchanted book without its stored enchantments: the same conversion dropped them). Probably #1660 too (its example is End city loot), but it's broader, so I left it open.

End city chests never held enchanted gear. The rolls aren't the problem: horizon_world::loot already runs
enchant_with_levels, enchant_randomly and set_potion, and the resulting LootStack carries the enchantments.
They were lost one step later. Chests filled when a structure is placed (structure_blocks.rs, the LootTable
block entity NBT of End city and other templates) turned each LootStack into an ItemStack with loot_item,
which keeps only the item, count, damage and exploration map. Mineshaft chest minecarts (unpack_entity_loot) did
the same.

Both now use loot_item_with_components, which vaults, trial spawners and decorated pots already use: it adds the
enchantments (as stored_enchantments on an enchanted book), the potion and the ominous bottle level (which the
chest path used to add by hand, the same way).

Vanilla reference

  • RandomizableContainer.unpackLootTable → LootTable.fill puts the generated stacks into the container as they
    are, components included
  • EnchantWithLevelsFunction (the End city treasure table's gear), EnchantRandomlyFunction, SetPotionFunction
  • EnchantedBookItem / ItemEnchantments: a book's enchantments are minecraft:stored_enchantments

The rolls themselves are unchanged, so the loot harnesses' comparisons stay as they were; this only stops dropping
their components when the chest is filled.

New test structure_blocks::tests::placed_chest_loot_keeps_its_enchantments_and_potions: enchanted boots keep
their enchantments, an enchanted book stores them, and a tipped arrow keeps its potion.

Self-check

pr_ready (tools/pr_ready.py on debian, against origin/main at 478b8c19c, 4 min 19 s)

Check Result
Scope ✅ 1 files, +44 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (15 s)
clippy ✅ (1 min 8 s)
tests: horizon-client ✅ 1242 passed (2 min 51 s)
doc tests ✅ 0 passed (4 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Not checked in game.

🤖 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/1911 **Author:** [@vlesmentie](https://github.com/vlesmentie) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/structure-chest-enchantments` --- ### 📝 Commits (1) - [`89d6e1c`](https://github.com/horizon-rust/horizon/commit/89d6e1c2a50112cb6d65de4cbfbe8af094ea5952) Structure chests keep the enchantments their loot rolled ### 📊 Changes **1 file changed** (+44 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/structure_blocks.rs` (+44 -9) </details> ### 📄 Description > 🤖 Opened by vlesmentie's AI agent (Claude Code, Claude Opus 5.5), not by vlesmentie themselves. ## What and why Fixes #1437. Fixes #1910 (a desert temple chest's enchanted book without its stored enchantments: the same conversion dropped them). Probably #1660 too (its example is End city loot), but it's broader, so I left it open. End city chests never held enchanted gear. The rolls aren't the problem: `horizon_world::loot` already runs `enchant_with_levels`, `enchant_randomly` and `set_potion`, and the resulting `LootStack` carries the enchantments. They were lost one step later. Chests filled when a structure is placed (`structure_blocks.rs`, the `LootTable` block entity NBT of End city and other templates) turned each `LootStack` into an `ItemStack` with `loot_item`, which keeps only the item, count, damage and exploration map. Mineshaft chest minecarts (`unpack_entity_loot`) did the same. Both now use `loot_item_with_components`, which vaults, trial spawners and decorated pots already use: it adds the enchantments (as `stored_enchantments` on an enchanted book), the potion and the ominous bottle level (which the chest path used to add by hand, the same way). ## Vanilla reference - `RandomizableContainer.unpackLootTable` → `LootTable.fill` puts the generated stacks into the container as they are, components included - `EnchantWithLevelsFunction` (the End city treasure table's gear), `EnchantRandomlyFunction`, `SetPotionFunction` - `EnchantedBookItem` / `ItemEnchantments`: a book's enchantments are `minecraft:stored_enchantments` The rolls themselves are unchanged, so the loot harnesses' comparisons stay as they were; this only stops dropping their components when the chest is filled. New test `structure_blocks::tests::placed_chest_loot_keeps_its_enchantments_and_potions`: enchanted boots keep their enchantments, an enchanted book stores them, and a tipped arrow keeps its potion. ## Self-check **pr_ready** (`tools/pr_ready.py` on debian, against origin/main at 478b8c19c, 4 min 19 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +44 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (15 s) | | clippy | ✅ (1 min 8 s) | | tests: horizon-client | ✅ 1242 passed (2 min 51 s) | | doc tests | ✅ 0 passed (4 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Not checked in game. 🤖 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: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#3857
No description provided.