[PR #7505] [MERGED] Mobs drop their DeathLootTable #7631

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

📋 Pull Request Information

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

Base: main ← Head: fix/mob-death-loot-table


📝 Commits (2)

  • 47a37f3 Mobs drop their DeathLootTable
  • a65b941 Death loot fixture: pass the level random die takes now

📊 Changes

6 files changed (+174 additions, -13 deletions)

View changed files

📝 crates/horizon-client/examples/probe/entity_death_loot_fixture.rs (+3 -1)
📝 crates/horizon-client/src/entity_nbt.rs (+58 -0)
📝 crates/horizon-client/src/game/creatures.rs (+1 -1)
📝 crates/horizon-client/src/mobs.rs (+5 -0)
📝 crates/horizon-client/src/mobs/drops.rs (+95 -9)
📝 crates/horizon-client/src/mobs/enderman.rs (+12 -2)

📄 Description

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

What and why

A mob with its own DeathLootTable drops its type's loot instead:

/summon minecraft:zombie ~ ~ ~ {DeathLootTable:"minecraft:entities/skeleton"}
/kill @e[type=zombie]

Vanilla drops bones and arrows; Horizon drops rotten flesh. Horizon never reads DeathLootTable: death_loot_table always names minecraft:entities/<type>. Data packs and mods use it for bosses and spawner mobs (found porting a dungeon mod whose tower bosses come from spawners with their own tables).

Fixing that alone isn't enough: drops::roll drops nothing when a table has no random_sequence, and a data pack's or a mod's tables mostly have none. Vanilla rolls such a table with the level's random.

Now:

  • DeathLootTable and DeathLootTableSeed are read with the mob (/summon, spawners, saves) and saved back (Mob.readAdditionalSaveData / addAdditionalSaveData).
  • Death rolls the mob's own table when it has one, else its type's (Mob.getLootTable).
  • The roll's random is the seed's own when DeathLootTableSeed is set, else the table's random sequence, else the level's random (LootTable.getRandomItems(params, seed, ...) → LootContext.Builder.create).

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

  • mobs.rs: Extra::death_loot_table and death_loot_seed.
  • entity_nbt.rs: mob_from_nbt reads them, mob_to_nbt writes them (the seed only when set, as vanilla).
  • mobs/drops.rs: death_loot_table returns the mob's own table first; roll takes the seed and the level random; die takes the level random (game/creatures.rs passes world.random).
  • Tests: a_mob_drops_its_own_death_loot_table (a table with no random sequence, with and without a seed, and a mob without one), a_death_loot_table_round_trips. The enderman test and the entity death loot fixture pass the new argument.

Vanilla reference

Mob.readAdditionalSaveData / addAdditionalSaveData (DeathLootTable, DeathLootTableSeed), Mob.getLootTable, Mob.getLootTableSeed, LivingEntity.dropFromLootTable, LootTable.getRandomItems(LootParams, long, Consumer), LootContext.Builder.withOptionalRandomSeed / create. tools/test_entity_death_loot_parity.py: 1,649 death-drop cases over 88 entity types match vanilla, as before.

Other projects' code

none

Test

Single player (horizon-ctl, temp home) and dedicated server (horizon-server), each on nightly c9d474d and on this branch. A NoAI zombie is summoned and killed, with a content mod installed whose boss table has no random sequence:

DeathLootTable Before After
the mod's boss table rotten flesh the boss loot (books, emeralds, iron gear...)
minecraft:entities/skeleton rotten flesh bones, arrows
none rotten flesh rotten flesh

The table stays with the mob across a save and reload (single player) and a server restart.

Self-check

pr_ready (tools/pr_ready.py --quick --base 0cf1b3d20 on DESKTOP-S9O4938, 7 min 31 s):

Check Result
Scope ✅ 6 files, +174 −13
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 613 run, FAILED (errors=1, skipped=1)
rustfmt ✅
clippy ✅
tests: horizon-client, horizon-client-lib ✅ 2152 passed
doc tests ✅
mod API up to date ✅
Parity ➖ not run (--quick); test_entity_death_loot_parity.py run by hand: 1,649 cases match

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/7505 **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/mob-death-loot-table` --- ### 📝 Commits (2) - [`47a37f3`](https://github.com/horizon-rust/horizon/commit/47a37f3bab0edde9760c760ecdefd69cc5c91dce) Mobs drop their DeathLootTable - [`a65b941`](https://github.com/horizon-rust/horizon/commit/a65b941358471b7778bb3528de676730b883ab7d) Death loot fixture: pass the level random die takes now ### 📊 Changes **6 files changed** (+174 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/entity_death_loot_fixture.rs` (+3 -1) 📝 `crates/horizon-client/src/entity_nbt.rs` (+58 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs.rs` (+5 -0) 📝 `crates/horizon-client/src/mobs/drops.rs` (+95 -9) 📝 `crates/horizon-client/src/mobs/enderman.rs` (+12 -2) </details> ### 📄 Description > 🤖 Opened by k3yh's AI agent (Claude Code, Claude Opus 5.5), not by k3yh personally. ## What and why A mob with its own `DeathLootTable` drops its type's loot instead: ``` /summon minecraft:zombie ~ ~ ~ {DeathLootTable:"minecraft:entities/skeleton"} /kill @e[type=zombie] ``` Vanilla drops bones and arrows; Horizon drops rotten flesh. Horizon never reads `DeathLootTable`: `death_loot_table` always names `minecraft:entities/<type>`. Data packs and mods use it for bosses and spawner mobs (found porting a dungeon mod whose tower bosses come from spawners with their own tables). Fixing that alone isn't enough: `drops::roll` drops nothing when a table has no `random_sequence`, and a data pack's or a mod's tables mostly have none. Vanilla rolls such a table with the level's random. Now: - `DeathLootTable` and `DeathLootTableSeed` are read with the mob (`/summon`, spawners, saves) and saved back (`Mob.readAdditionalSaveData` / `addAdditionalSaveData`). - Death rolls the mob's own table when it has one, else its type's (`Mob.getLootTable`). - The roll's random is the seed's own when `DeathLootTableSeed` is set, else the table's random sequence, else the level's random (`LootTable.getRandomItems(params, seed, ...)` → `LootContext.Builder.create`). ## 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 - `mobs.rs`: `Extra::death_loot_table` and `death_loot_seed`. - `entity_nbt.rs`: `mob_from_nbt` reads them, `mob_to_nbt` writes them (the seed only when set, as vanilla). - `mobs/drops.rs`: `death_loot_table` returns the mob's own table first; `roll` takes the seed and the level random; `die` takes the level random (`game/creatures.rs` passes `world.random`). - Tests: `a_mob_drops_its_own_death_loot_table` (a table with no random sequence, with and without a seed, and a mob without one), `a_death_loot_table_round_trips`. The enderman test and the entity death loot fixture pass the new argument. ## Vanilla reference `Mob.readAdditionalSaveData` / `addAdditionalSaveData` (`DeathLootTable`, `DeathLootTableSeed`), `Mob.getLootTable`, `Mob.getLootTableSeed`, `LivingEntity.dropFromLootTable`, `LootTable.getRandomItems(LootParams, long, Consumer)`, `LootContext.Builder.withOptionalRandomSeed` / `create`. `tools/test_entity_death_loot_parity.py`: 1,649 death-drop cases over 88 entity types match vanilla, as before. ## Other projects' code none ## Test Single player (`horizon-ctl`, temp home) and dedicated server (`horizon-server`), each on nightly c9d474d and on this branch. A NoAI zombie is summoned and killed, with a content mod installed whose boss table has no random sequence: | `DeathLootTable` | Before | After | | --- | --- | --- | | the mod's boss table | rotten flesh | the boss loot (books, emeralds, iron gear...) | | `minecraft:entities/skeleton` | rotten flesh | bones, arrows | | none | rotten flesh | rotten flesh | The table stays with the mob across a save and reload (single player) and a server restart. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base 0cf1b3d20` on DESKTOP-S9O4938, 7 min 31 s): | Check | Result | | --- | --- | | Scope | ✅ 6 files, +174 −13 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 613 run, FAILED (errors=1, skipped=1) | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-lib | ✅ 2152 passed | | doc tests | ✅ | | mod API up to date | ✅ | | Parity | ➖ not run (--quick); `test_entity_death_loot_parity.py` run by hand: 1,649 cases match | 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:21:06 +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#7631
No description provided.