mojira.dev
MC-44283

Mobs which can pick up loot prefer items with less durability over an item of the same type they are already wearing

The bug

Mobs, if they have the ability to pick up items, normally only replace armour and swords with other armour or swords of better quality. However, it seems there is a bug in this rule that makes them pick up items whose damage state is more damaged than what they already have, rather than less damaged.

How to reproduce

  1. Summon a mob which can pick up items

    /summon husk ~ ~ ~ {CanPickUpLoot:1b}
  2. Set the mobGriefing gamerule to true if it is not already

    /gamerule mobGriefing true
  3. Throw a slightly damaged chestplate at the mob

    /give @p diamond_chestplate 1 1
  4. Throw a nearly broken chestplate of the same material at the mob

    /give @p diamond_chestplate 1 500

    → You will notice that the mob picked up the nearly broken chestplate and dropped the slightly damaged one

Description of the screenshots

[media]

- zombie with enchanted helmet and chestplate.

[media]

- zombie after replacing its armour with the inferior unenchanted versions seen held by the player in the first screenshot.

[media]

- The armour drops released by the zombie when it took that armour.

[media]

- The damaged armour, neatly returned when the mob is killed (making it infinitely reusable for the same trick).

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The method net.minecraft.entity.EntityLiving.updateEquipmentIfNeeded(EntityItem) checks for swords and armor if the damage of the item to pick up is higher than the one it is already wearing.

Note: If the MCP names are correct (which seems to be the case) the method should probably call the method getItemDamage() instead of getMetadata() in case the latter one gets changed to not return the damage.

Linked issues

Attachments

Comments 11

Side note: I now have about two chests full of undamaged armour 'harvested' this way. I was under the impression that the intended behaviour was that armour drops were impossible to get without human interaction, much like exp orbs.

Someone on youtube figured out that apparently, it is caused by the one factor I didn't specifically test, namely durability.

It seems the actual bug is that they favour items with lower durability, and will even drop enchanted ones if they get a replacement with lower durability.

This explains a lot of the odd side behaviour I've had when testing this concerning them not dropping stuff (meaning what they were wearing was even poorer quality), and also explains why I'm getting practically only undamaged items.

Deleted account

Is this still a concern in the current Minecraft version 14w10c / Launcher version 1.3.10 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Deleted account

Is this still a concern in the current Minecraft version 14w19a / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Difficult to test for me, since I've done all my tests on a multiplayer server which doesn't use betas. But it is still present in 1.7.9.

I tried it on a new game in 14w19a, but it is almost impossible to test without a zombie/skeleton spawner, on Hard difficulty, in an area which has reached high regional difficulty. I found a spawner, but (probably due to low regional difficulty) I never got a decent amount of armoured mobs from it.

1 more comments

Well, it wasn't fixed in 1.8, so I assume it must still be in there? As I said, it's hard to test for me.

Structured the report a little bit and removed the part describing MC-112198.

Confirmed for 1.13.1.

How did you test the bug under 1.13.1 @Kraif?

Zombies no longer prefer more damaged equipment over less damaged equipment in my 1.13.1 world.
They still toggle items as per MC-113131 but only for non-damaged equipment without any NBT tags and damaged equipment.
I believe this is because the equipment damage is stored in an NBT tag, as can be seen when displaying the advanced tooltip of damaged equipment, thus not switching because of durability but the NBT condition.

Fixed in 1.15.2 or earlier.

nyerguds

(Unassigned)

Confirmed

Mob behaviour

CanPickUpLoot, armor, damage-value, item, mob, skeleton, zombie

Minecraft 1.7.4, Minecraft 1.7.9, Minecraft 16w42a, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w05a, Minecraft 1.13.1

1.15.2

Retrieved