[PR #6275] [MERGED] Drop the item a piglin was admiring when it zombifies #6760

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6275
Author: @MSedgeMC
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/piglin-conversion-offhand


📝 Commits (1)

  • 7671485 Drop the item a piglin was admiring when it zombifies

📊 Changes

1 file changed (+59 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/mobs/piglin.rs (+59 -0)

📄 Description

Piglin.finishConversion starts with the admire:

// javap -p -c on Piglin
 1: invokestatic  PiglinAi.cancelAdmiring:(ServerLevel, Piglin)V
 6: getfield inventory; 9: invokevirtual SimpleContainer.removeAllItems
13-19: forEach(stack -> spawnAtLocation(level, stack))
25: invokespecial AbstractPiglin.finishConversion      // the conversion itself

and PiglinAi.cancelAdmiring spawns getOffhandItem() where the piglin stands before
setItemInHand(OFF_HAND, EMPTY).

Horizon's conversion carried the off hand over (conversion::single with KEEP_ALL, which is
right for ConversionParams.single(this, true, true)), but nothing cancelled the admire first.
The piglin converts holding the gold it was admiring, and that item should have dropped at its
feet.

Proven: on the build VM, cargo test -q -p horizon-client --lib a_converted_piglin_drops_the_item_it_was_admiring
→ 1 passed: the tick that converts a piglin admiring a gold ingot emits a
DropItem of that ingot and the new mob's off hand is empty.

Not proven: not checked in game. The check is a piglin admiring gold outside the Nether,
waiting for it to zombify, and watching the item drop.

Two limits worth naming:

  • Piglin.finishConversion also dumps its 8-slot inventory. Horizon does not model a piglin
    inventory (there is no bartering container), so there is nothing to drop; when one is added,
    its removeAllItems belongs in the same place as this drop.
  • The drop is spawnAtLocation at the piglin's own position, so it inherits no motion; a vanilla
    item entity also gets a random 0.2 offset in each axis from ItemEntity's constructor. The
    same simplification is already used by the other DropItem emitters.

🔄 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/6275 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/piglin-conversion-offhand` --- ### 📝 Commits (1) - [`7671485`](https://github.com/horizon-rust/horizon/commit/7671485c32aec383921deb0a059c52d75eb484a6) Drop the item a piglin was admiring when it zombifies ### 📊 Changes **1 file changed** (+59 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/piglin.rs` (+59 -0) </details> ### 📄 Description `Piglin.finishConversion` starts with the admire: ```java // javap -p -c on Piglin 1: invokestatic PiglinAi.cancelAdmiring:(ServerLevel, Piglin)V 6: getfield inventory; 9: invokevirtual SimpleContainer.removeAllItems 13-19: forEach(stack -> spawnAtLocation(level, stack)) 25: invokespecial AbstractPiglin.finishConversion // the conversion itself ``` and `PiglinAi.cancelAdmiring` spawns `getOffhandItem()` where the piglin stands before `setItemInHand(OFF_HAND, EMPTY)`. Horizon's conversion carried the off hand over (`conversion::single` with `KEEP_ALL`, which is right for `ConversionParams.single(this, true, true)`), but nothing cancelled the admire first. The piglin converts holding the gold it was admiring, and that item should have dropped at its feet. **Proven:** on the build VM, `cargo test -q -p horizon-client --lib a_converted_piglin_drops_the_item_it_was_admiring` → `1 passed`: the tick that converts a piglin admiring a gold ingot emits a `DropItem` of that ingot and the new mob's off hand is empty. **Not proven:** not checked in game. The check is a piglin admiring gold outside the Nether, waiting for it to zombify, and watching the item drop. Two limits worth naming: - `Piglin.finishConversion` also dumps its 8-slot inventory. Horizon does not model a piglin inventory (there is no bartering container), so there is nothing to drop; when one is added, its `removeAllItems` belongs in the same place as this drop. - The drop is `spawnAtLocation` at the piglin's own position, so it inherits no motion; a vanilla item entity also gets a random `0.2` offset in each axis from `ItemEntity`'s constructor. The same simplification is already used by the other `DropItem` emitters. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:26:13 +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#6760
No description provided.