mojira.dev
MC-108124

Tool holding {CanPickUpLoot:1b} mobs only pick up swords

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

  1. Use the following command

    /summon husk ~ ~ ~ {CanPickUpLoot:1b,HandItems:[{id:"iron_shovel",Count:1b},{}]}
  2. Set the mobGriefing gamerule to true if it is not already

    /gamerule mobGriefing true
  3. Throw a diamond shovel at the husk
    → It won't pick it up

  4. 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)

Linked issues

Comments 9

Confirmed for

  • 16w39c

How to reproduce

  1. Use the following command

    /summon zombie ~ ~ ~ {CanPickUpLoot:1b,HandItems:[{id:"iron_shovel",Count:1b},{}]}
  2. Throw a diamond shovel at the zombie
    → It won't pick it up

  3. 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)

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

Duplicates MC-104880 (or vice versa)
Relates to MC-44283 like @unknown said

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.

I can no longer reproduce this bug.

I am also no longer able to reproduce this issue in 21w03a.

[MOD] Greymagic27

I'm unable to reproduce this in 21w03a.

Roy Sajima

(Unassigned)

Confirmed

(Unassigned)

CanPickUpLoot, mob, sword

Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 1.11, Minecraft 1.11.2, ..., Minecraft 1.13, Minecraft 1.13.1, 1.15.1, 1.15.2 Pre-release 2, 20w46a

Retrieved