[PR #2190] [MERGED] Piglins accept only gold ingots by hand and keep other loved items #4088

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

📋 Pull Request Information

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

Base: main ← Head: fix/piglin-loved-items


📝 Commits (3)

  • 6875c44 Piglins accept only gold ingots by hand, keep other loved items, pick up more
  • 0c22d75 Satisfy clippy
  • e60cbe8 Keep whole nugget stacks and picked-up enchantments on piglins

📊 Changes

6 files changed (+239 additions, -33 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+23 -0)
📝 crates/horizon-client/src/game/piglins.rs (+192 -33)
📝 crates/horizon-client/src/mobs.rs (+2 -0)
📝 crates/horizon-client/src/mobs/drops.rs (+8 -0)
📝 crates/horizon-client/src/mobs/finalize.rs (+8 -0)
📝 crates/horizon-client/src/mobs/piglin.rs (+6 -0)

📄 Description

What and why

Right-clicking a piglin with any item from the #piglin_loved tag (gold block, golden sword, clock, bell, ...) was accepted: the piglin admired it, the item was used up, and when the admiring ended the piglin threw the item straight back. In vanilla only gold ingots are accepted from the hand. Everything else is left alone and nothing is consumed.

This changes three things for piglins:

  • give_piglin now accepts only piglin currency (the gold ingot) from the player's hand.
  • When a piglin finishes admiring something that is not a gold ingot (for example a golden sword it picked up from the ground), it keeps it. It wears it if it fits an empty slot (or a wanted item over an unwanted one), otherwise it stores it in an eight-slot inventory. Before, it threw every such item at the player. The inventory is saved with the piglin (Inventory) and drops when the piglin dies.
  • Piglins now pick up what vanilla's wantsToPickup lets them pick up, not only loved items: gold nuggets (when there is room), food from #piglin_food (when they have not eaten for 200 ticks; the food is used up), and any item that fits an empty equipment slot. Items from #piglin_repellents are ignored. The old gold nugget branch could never be reached.

Left out on purpose: when a new armour piece or weapon competes with one a piglin already wears and neither is loved or preferred, vanilla compares armour value and attack damage. Here the piglin keeps what it has. Baby piglins still skip item pickup entirely, as before.

Vanilla reference

  • PiglinAi.mobInteract and PiglinAi.canAdmire: only isPiglinCurrency() is accepted from the hand, otherwise PASS.
  • PiglinAi.stopHoldingOffHandItem: bartering only for currency, otherwise equipItemIfPossible and then putInInventory.
  • PiglinAi.wantsToPickup and PiglinAi.pickUpItem: nuggets, food and gear branches.
  • Piglin.canReplaceCurrentItem, Mob.equipItemIfPossible, Piglin.dropCustomDeathLoot, InventoryCarrier (Inventory tag).

Self-check

cargo check -p horizon-client passes.


🔄 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/2190 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/piglin-loved-items` --- ### 📝 Commits (3) - [`6875c44`](https://github.com/horizon-rust/horizon/commit/6875c44bbe4974ec6d807808536001301bc0043f) Piglins accept only gold ingots by hand, keep other loved items, pick up more - [`0c22d75`](https://github.com/horizon-rust/horizon/commit/0c22d75a2e6a88fa8daef1c8c59c34d2f154c6f2) Satisfy clippy - [`e60cbe8`](https://github.com/horizon-rust/horizon/commit/e60cbe8d4df0ad5ea87d571984f2bfd8119cfca8) Keep whole nugget stacks and picked-up enchantments on piglins ### 📊 Changes **6 files changed** (+239 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+23 -0) 📝 `crates/horizon-client/src/game/piglins.rs` (+192 -33) 📝 `crates/horizon-client/src/mobs.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs/drops.rs` (+8 -0) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+8 -0) 📝 `crates/horizon-client/src/mobs/piglin.rs` (+6 -0) </details> ### 📄 Description ## What and why Right-clicking a piglin with any item from the `#piglin_loved` tag (gold block, golden sword, clock, bell, ...) was accepted: the piglin admired it, the item was used up, and when the admiring ended the piglin threw the item straight back. In vanilla only gold ingots are accepted from the hand. Everything else is left alone and nothing is consumed. This changes three things for piglins: - `give_piglin` now accepts only piglin currency (the gold ingot) from the player's hand. - When a piglin finishes admiring something that is not a gold ingot (for example a golden sword it picked up from the ground), it keeps it. It wears it if it fits an empty slot (or a wanted item over an unwanted one), otherwise it stores it in an eight-slot inventory. Before, it threw every such item at the player. The inventory is saved with the piglin (`Inventory`) and drops when the piglin dies. - Piglins now pick up what vanilla's `wantsToPickup` lets them pick up, not only loved items: gold nuggets (when there is room), food from `#piglin_food` (when they have not eaten for 200 ticks; the food is used up), and any item that fits an empty equipment slot. Items from `#piglin_repellents` are ignored. The old gold nugget branch could never be reached. Left out on purpose: when a new armour piece or weapon competes with one a piglin already wears and neither is loved or preferred, vanilla compares armour value and attack damage. Here the piglin keeps what it has. Baby piglins still skip item pickup entirely, as before. ## Vanilla reference - `PiglinAi.mobInteract` and `PiglinAi.canAdmire`: only `isPiglinCurrency()` is accepted from the hand, otherwise `PASS`. - `PiglinAi.stopHoldingOffHandItem`: bartering only for currency, otherwise `equipItemIfPossible` and then `putInInventory`. - `PiglinAi.wantsToPickup` and `PiglinAi.pickUpItem`: nuggets, food and gear branches. - `Piglin.canReplaceCurrentItem`, `Mob.equipItemIfPossible`, `Piglin.dropCustomDeathLoot`, `InventoryCarrier` (`Inventory` tag). ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:35 +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#4088
No description provided.