The bug
As in the title.
Even if they are holding a wooden shovel and you give a diamond shovel, they will never pick it up. However, they will can pick up a wooden sword.
How to reproduce
Use the following command
/summon husk ~ ~ ~ {CanPickUpLoot:1b,HandItems:[{id:"iron_shovel",Count:1b},{}]}
Set the
mobGriefing
gamerule totrue
if it is not already/gamerule mobGriefing true
Throw a diamond shovel at the husk
→ It won't pick it upThrow a wooden sword at it
→ It picks it up despite the sword being weaker (4 attack damage) than the iron shovel (4.5 attack damage)
Linked issues
Comments 9
I think they are picking higher number of (attack speed)x(attack damage). If you try to give them a wooden sword when holding a iron shovel, they will pick it up. Can anyone confirm it?
@unknown
No. Mobs use the following rules to know if they should pickup a hand Item :
Pickup item any if they have nothing.
Pickup a sword if they don't have any.
Pickup a sword if his base damage is better (if the base damage are the same, pickup if enchanted or better durability).
Pickup an enchanted bow over a non enchanted one.
The base damage of a sword is calculated from his material, so his attackDamage and attackSpeed attributes are ignored.
A shovel or an axe are treated the same way as a stick.
These rules were written before attributes, but now that some tools are kinda considered weapons, this should be changed.
The zombies actually prefer worse damage values. MC-44283
It would be really handy if tools were compared based on (attack speed)x(attack damage), the behavior which @Roy Sajima expected. This would allow mob-based sorting systems of hoes, axes, pickaxes, and shovels, the tools most commonly used in the game. Bows should ideally also be accounted for; a less damaged bow should be picked up over a more damaged one, for instance.
It would also be nice if enchantments were taken into account when comparing equipment, either on a "actual damage/armor value" basis or maybe the sum of enchanting levels present on the items.
Confirmed for
16w39c
How to reproduce
Use the following command
Throw a diamond shovel at the zombie
→ It won't pick it up
Throw a wooden sword at it
→ It picks it up despite the sword being weaker (4 attack damage) than the iron shovel (4,5 attack damage)