[PR #1930] [CLOSED] Generated chests keep the enchantments their loot rolls #3872

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1930
Author: @levzzz5154
Created: 10/25/2026
Status: ❌ Closed

Base: main ← Head: fix/end-city-loot-enchantments


📝 Commits (1)

  • c68365e Generated chests keep the enchantments their loot rolls

📊 Changes

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

View changed files

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

📄 Description

🤖 Opened by levzzz5154's AI agent ([CC], deepseek-v4.1-flash), not by levzzz5154.

What and why

Fixes #1437
Fixes #1660.

End city chests never held enchanted gear. The rolls do carry the enchantments — horizon_world::loot
implements enchant_with_levels and enchant_randomly — but the chest items were built with
structure_blocks::loot_item, which keeps only the item id, count and damage: enchantments, stored enchantments
and potions were dropped on the way into the chest.

loot_item_with_components (already in the file, used by decorated pots) keeps them, and both places that unpack
a loot table into a container now use it: the chests a chunk's generation places, and the chest minecart a
mineshaft places. That is what RandomizableContainer.unpackLootTable does with the rolled stacks — they go in
as they are.

Vanilla reference

  • RandomizableContainer.unpackLootTable: this.setItem(slot, itemStack) for each LootTable.getRandomItems
    result, components included.
  • EnchantWithLevelsFunction.apply / EnchantRandomlyFunction.apply: the enchantments are added to the stack's
    DataComponents.ENCHANTMENTS (or STORED_ENCHANTMENTS for a book) before it is placed.

Verification

Rolling minecraft:chests/end_city_treasure over 40 seeds (LootData::fill, the path the chest uses): 82 of 268
stacks carry enchantments, and before this change none of them reached the chest. As an item, a rolled diamond
pickaxe keeps efficiency 5, fortune 3, unbreaking 3.

a_rolled_stack_keeps_its_enchantments_as_a_chest_item pins the conversion: armour keeps minecraft:enchantments,
a book gets minecraft:stored_enchantments and no regular ones.

Scope

One file, +30 −9 (crates/horizon-client/src/structure_blocks.rs).

🤖 Generated with [CC].

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 7fd1f3118, 2 min 0 s)

Check Result
Scope ✅ 1 files, +30 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ❌ failed (9 s)
tests: horizon-client ✅ 1243 passed (1 min 44 s)
doc tests ✅ 0 passed (1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 269 affected, to run in CI (--quick)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

clippy fails on crates/horizon-client/src/mobs/axolotl.rs:169 (overly_complex_bool_expr), which fails the same way on upstream/main at 7fd1f3118: nothing in this branch touches it.

🤖 Generated with [CC].


🔄 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/1930 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/end-city-loot-enchantments` --- ### 📝 Commits (1) - [`c68365e`](https://github.com/horizon-rust/horizon/commit/c68365e1cc926b3cebcec8b383c55c5475441109) Generated chests keep the enchantments their loot rolls ### 📊 Changes **1 file changed** (+30 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/structure_blocks.rs` (+30 -9) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent ([CC], deepseek-v4.1-flash), not by levzzz5154. ## What and why Fixes #1437 Fixes #1660. End city chests never held enchanted gear. The rolls do carry the enchantments — `horizon_world::loot` implements `enchant_with_levels` and `enchant_randomly` — but the chest items were built with `structure_blocks::loot_item`, which keeps only the item id, count and damage: enchantments, stored enchantments and potions were dropped on the way into the chest. `loot_item_with_components` (already in the file, used by decorated pots) keeps them, and both places that unpack a loot table into a container now use it: the chests a chunk's generation places, and the chest minecart a mineshaft places. That is what `RandomizableContainer.unpackLootTable` does with the rolled stacks — they go in as they are. ## Vanilla reference - `RandomizableContainer.unpackLootTable`: `this.setItem(slot, itemStack)` for each `LootTable.getRandomItems` result, components included. - `EnchantWithLevelsFunction.apply` / `EnchantRandomlyFunction.apply`: the enchantments are added to the stack's `DataComponents.ENCHANTMENTS` (or `STORED_ENCHANTMENTS` for a book) before it is placed. ## Verification Rolling `minecraft:chests/end_city_treasure` over 40 seeds (`LootData::fill`, the path the chest uses): 82 of 268 stacks carry enchantments, and before this change none of them reached the chest. As an item, a rolled diamond pickaxe keeps `efficiency 5, fortune 3, unbreaking 3`. `a_rolled_stack_keeps_its_enchantments_as_a_chest_item` pins the conversion: armour keeps `minecraft:enchantments`, a book gets `minecraft:stored_enchantments` and no regular ones. ## Scope One file, +30 −9 (`crates/horizon-client/src/structure_blocks.rs`). 🤖 Generated with [[CC]](https://github.com/levzzz5154/horizon). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 7fd1f3118, 2 min 0 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +30 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ❌ failed (9 s) | | tests: horizon-client | ✅ 1243 passed (1 min 44 s) | | doc tests | ✅ 0 passed (1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 269 affected, to run in CI (--quick) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `clippy` fails on `crates/horizon-client/src/mobs/axolotl.rs:169` (`overly_complex_bool_expr`), which fails the same way on `upstream/main` at 7fd1f3118: nothing in this branch touches it. 🤖 Generated with [[CC]](https://github.com/levzzz5154/horizon). --- <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:55 +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#3872
No description provided.