[PR #4241] [MERGED] Endermen drop the block they carry when killed #5511

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4241
Author: @d3grando
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3513-enderman-carried-drop


📝 Commits (2)

  • 7a1a5e8 Drop a killed enderman's carried block
  • 956bd64 Death loot parity: endermen carrying each holdable block

📊 Changes

6 files changed (+186 additions, -6 deletions)

View changed files

📝 crates/horizon-client/examples/probe/entity_death_loot_fixture.rs (+37 -1)
📝 crates/horizon-client/src/game/creatures.rs (+14 -0)
📝 crates/horizon-client/src/mobs/drops.rs (+15 -2)
📝 crates/horizon-client/src/mobs/enderman.rs (+107 -1)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityDeathLootOracle.java (+1 -0)
📝 tools/test_entity_death_loot_parity.py (+12 -2)

📄 Description

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

What and why

When you killed an enderman that was carrying a block, the block was lost. In vanilla it drops.

Enderman.dropCustomDeathLoot calls Monster.dropCustomDeathLoot first. Then, if getCarriedBlock() is set, it builds a diamond axe, enchants it with EnchantmentHelper.enchantItemFromProvider(.., VanillaEnchantmentProviders.ENDERMAN_LOOT_DROP, ..) (enchantment_provider/enderman_loot_drop.json: a single Silk Touch I), and spawns BlockState.getDrops of the carried state with that axe as TOOL and the enderman as THIS_ENTITY. Horizon's death drops (mobs::drops::die → Game::drop_death_loot) never read m.extra.carried, so the block disappeared with the enderman.

The fix:

  • mobs::drops::die now adds a Drop::CarriedBlock(state) for an enderman that carries a block. It goes right after the equipment drops, inside the shouldDropLoot/doMobLoot branch, which is where vanilla's dropCustomDeathLoot runs.
  • mobs::enderman::carried_block_drops rolls the block's loot table with carried_block_tool() (a diamond axe with Silk Touch I), with the enderman as the this entity. It draws from the table's random sequence, or the level random if the table has none. drop_death_loot spawns each result like any other death drop (spawnAtLocation).

The result: a grass block comes back as a grass block (not dirt), a nylium as nylium, and TNT, flowers and so on as themselves.

Part of #3513: its Enderman.dropCustomDeathLoot row ("an Enderman killed while holding a block drops no block").

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

Vanilla reference

  • net.minecraft.world.entity.monster.Enderman.dropCustomDeathLoot(ServerLevel, DamageSource, boolean): calls super, then getCarriedBlock, new ItemStack(Items.DIAMOND_AXE), EnchantmentHelper.enchantItemFromProvider(.., VanillaEnchantmentProviders.ENDERMAN_LOOT_DROP, ..), LootParams.Builder with ORIGIN, TOOL and THIS_ENTITY, BlockState.getDrops, and spawnAtLocation for each drop.
  • data/minecraft/enchantment_provider/enderman_loot_drop.json: minecraft:single, minecraft:silk_touch, level 1. A constant level draws nothing from the mob's random.
  • LivingEntity.dropAllDeathLoot: dropCustomDeathLoot runs only when shouldDropLoot and doMobLoot both hold.

Checked by tools/test_entity_death_loot_parity.py, extended in the second commit. VanillaEntityDeathLootOracle now sets the victim's carried block (Enderman.setCarriedBlock). The corpus adds 54 cases: an enderman carrying each enderman_holdable block (grass, dirt, podzol, mycelium, mud, moss, sand, gravel, flowers, mushrooms, TNT, cactus, clay, pumpkins, melon, nylium, fungi, roots, cactus flower), killed by a player with Looting III and by generic damage.

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand on Windows 11:

  • cargo fmt --all -- --check: clean
  • cargo clippy --profile fast -p horizon-client --all-targets -- -D warnings: clean
  • cargo test --profile fast -p horizon-client --lib mobs::enderman: 2 passed. This includes the new a_killed_enderman_drops_its_carried_block, which uses the real 26.3 data. An enderman carrying a grass block, a crimson nylium or TNT drops exactly that block; with doMobLoot off it drops nothing.
    • Before (the die branch disabled, test unchanged): FAILED, assertion left == right failed: minecraft:grass_block, left: [], right: ["minecraft:grass_block 1"]
    • After: ok
  • cargo test --profile fast -p horizon-client --lib drops: 2 passed
  • python tools/test_entity_death_loot_parity.py (JDK 25.0.5):
    • Before (fix disabled): 54 differing cases, all enderman-carried-*. Vanilla drops e.g. drop minecraft:gravel 1 after the pearls; Horizon dropped nothing.
    • After: 1,649 death-drop cases over 88 entity types match vanilla (21,603 lines)
  • In game, single player (server thread), with a fast build of this branch and the same build with the fix disabled. Same world seed, same spot, midnight with night vision. An enderman in a glass cage picks up a grass block. It is then teleported onto a stone floor in front of the player and killed with /kill.
    • Before: nothing drops (entities: no items).
    • After: a minecraft:grass_block item drops next to the ender pearl.

Screenshots

before: an enderman carrying a grass block is killed: only nothing is left

after: it drops the grass block it carried, beside its ender pearl

Before: the enderman holding a grass block is killed and leaves nothing on the stone floor.
After: the same kill leaves a grass block item (and its ender pearl) on the floor.

🤖 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/4241 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3513-enderman-carried-drop` --- ### 📝 Commits (2) - [`7a1a5e8`](https://github.com/horizon-rust/horizon/commit/7a1a5e8e88105b4ab3597dfcd5e28a8f8955a5aa) Drop a killed enderman's carried block - [`956bd64`](https://github.com/horizon-rust/horizon/commit/956bd64c5d183f51f317f202125c2675d343ba93) Death loot parity: endermen carrying each holdable block ### 📊 Changes **6 files changed** (+186 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/entity_death_loot_fixture.rs` (+37 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+14 -0) 📝 `crates/horizon-client/src/mobs/drops.rs` (+15 -2) 📝 `crates/horizon-client/src/mobs/enderman.rs` (+107 -1) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityDeathLootOracle.java` (+1 -0) 📝 `tools/test_entity_death_loot_parity.py` (+12 -2) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why When you killed an enderman that was carrying a block, the block was lost. In vanilla it drops. `Enderman.dropCustomDeathLoot` calls `Monster.dropCustomDeathLoot` first. Then, if `getCarriedBlock()` is set, it builds a diamond axe, enchants it with `EnchantmentHelper.enchantItemFromProvider(.., VanillaEnchantmentProviders.ENDERMAN_LOOT_DROP, ..)` (`enchantment_provider/enderman_loot_drop.json`: a single Silk Touch I), and spawns `BlockState.getDrops` of the carried state with that axe as `TOOL` and the enderman as `THIS_ENTITY`. Horizon's death drops (`mobs::drops::die` → `Game::drop_death_loot`) never read `m.extra.carried`, so the block disappeared with the enderman. The fix: - `mobs::drops::die` now adds a `Drop::CarriedBlock(state)` for an enderman that carries a block. It goes right after the equipment drops, inside the `shouldDropLoot`/`doMobLoot` branch, which is where vanilla's `dropCustomDeathLoot` runs. - `mobs::enderman::carried_block_drops` rolls the block's loot table with `carried_block_tool()` (a diamond axe with Silk Touch I), with the enderman as the `this` entity. It draws from the table's random sequence, or the level random if the table has none. `drop_death_loot` spawns each result like any other death drop (`spawnAtLocation`). The result: a grass block comes back as a grass block (not dirt), a nylium as nylium, and TNT, flowers and so on as themselves. Part of #3513: its `Enderman.dropCustomDeathLoot` row ("an Enderman killed while holding a block drops no block"). ## 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 ## Vanilla reference - `net.minecraft.world.entity.monster.Enderman.dropCustomDeathLoot(ServerLevel, DamageSource, boolean)`: calls super, then `getCarriedBlock`, `new ItemStack(Items.DIAMOND_AXE)`, `EnchantmentHelper.enchantItemFromProvider(.., VanillaEnchantmentProviders.ENDERMAN_LOOT_DROP, ..)`, `LootParams.Builder` with `ORIGIN`, `TOOL` and `THIS_ENTITY`, `BlockState.getDrops`, and `spawnAtLocation` for each drop. - `data/minecraft/enchantment_provider/enderman_loot_drop.json`: `minecraft:single`, `minecraft:silk_touch`, level 1. A constant level draws nothing from the mob's random. - `LivingEntity.dropAllDeathLoot`: `dropCustomDeathLoot` runs only when `shouldDropLoot` and `doMobLoot` both hold. Checked by `tools/test_entity_death_loot_parity.py`, extended in the second commit. `VanillaEntityDeathLootOracle` now sets the victim's carried block (`Enderman.setCarriedBlock`). The corpus adds 54 cases: an enderman carrying each `enderman_holdable` block (grass, dirt, podzol, mycelium, mud, moss, sand, gravel, flowers, mushrooms, TNT, cactus, clay, pumpkins, melon, nylium, fungi, roots, cactus flower), killed by a player with Looting III and by generic damage. ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand on Windows 11: - `cargo fmt --all -- --check`: clean - `cargo clippy --profile fast -p horizon-client --all-targets -- -D warnings`: clean - `cargo test --profile fast -p horizon-client --lib mobs::enderman`: 2 passed. This includes the new `a_killed_enderman_drops_its_carried_block`, which uses the real 26.3 data. An enderman carrying a grass block, a crimson nylium or TNT drops exactly that block; with `doMobLoot` off it drops nothing. - Before (the `die` branch disabled, test unchanged): **FAILED**, `assertion left == right failed: minecraft:grass_block, left: [], right: ["minecraft:grass_block 1"]` - After: **ok** - `cargo test --profile fast -p horizon-client --lib drops`: 2 passed - `python tools/test_entity_death_loot_parity.py` (JDK 25.0.5): - Before (fix disabled): 54 differing cases, all `enderman-carried-*`. Vanilla drops e.g. `drop minecraft:gravel 1` after the pearls; Horizon dropped nothing. - After: `1,649 death-drop cases over 88 entity types match vanilla (21,603 lines)` - In game, single player (server thread), with a `fast` build of this branch and the same build with the fix disabled. Same world seed, same spot, midnight with night vision. An enderman in a glass cage picks up a grass block. It is then teleported onto a stone floor in front of the player and killed with `/kill`. - Before: nothing drops (`entities`: no items). - After: a `minecraft:grass_block` item drops next to the ender pearl. ## Screenshots ![before: an enderman carrying a grass block is killed: only nothing is left](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3513-enderman-carried-drop-1.png) ![after: it drops the grass block it carried, beside its ender pearl](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3513-enderman-carried-drop-2.png) Before: the enderman holding a grass block is killed and leaves nothing on the stone floor. After: the same kill leaves a grass block item (and its ender pearl) on the floor. 🤖 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 05:13:05 +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#5511
No description provided.