If Gold Nuggets are included under the #piglin_loved item tag and then a stack of them is dropped near a Piglin, it will pick up all items from the stack instead of picking up only one of them. This is inconsistent with other items when included in the item tag since it will pick up only one of them when in a stack.
The bug is caused by the fix of
- Download and then install the data pack below for easier reproduction.
- Spawn a Piglin, and then drop a stack of Gold Ingots or Netherite Ingots near it.
→ The Piglin picks up only one item in the stack.
- Drop a stack of Gold Nuggets near the same mob.
→ The Piglin picks up all items in the stack.
The code below is based on a 1.16 Pre-release 3 mapping provided by Yarn from FabricMC.
It is used to fix the mentioned bug and checks if the dropped item is a Gold Nugget:
If it is a Gold Nugget, the Piglin will pick up all items from the stack due to the piglin.sendPickup(drop, drop.getStack().getCount()); method. Otherwise, it will pick up only one item from the stack due to the piglin.sendPickup(drop, 1); method.