-
Bug
-
Resolution: Fixed
-
Minecraft 1.7.4, Minecraft 1.7.9, Minecraft 16w42a, Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 18w05a, Minecraft 1.13.1
-
Confirmed
-
Survival
-
Mob behaviour
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
- Summon a mob which can pick up items
/summon husk ~ ~ ~ {CanPickUpLoot:1b}
- Set the mobGriefing gamerule to true if it is not already
/gamerule mobGriefing true
- Throw a slightly damaged chestplate at the mob
/give @p diamond_chestplate 1 1
- 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
2014-01-07_21.14.39.png - zombie with enchanted helmet and chestplate.
2014-01-07_21.14.47.png - zombie after replacing its armour with the inferior unenchanted versions seen held by the player in the first screenshot.
2014-01-07_21.15.28.png - The armour drops released by the zombie when it took that armour.
2014-01-07_21.15.50.png - 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.
- relates to
-
MC-174359 Piglins prefer using an unenchanted gold item instead of an enchanted gold item
- Resolved
-
MC-108124 Tool holding {CanPickUpLoot:1b} mobs only pick up swords
- Resolved
-
MC-113131 Mob item pick up behavior is not distinct resulting in mobs constantly dropping and picking up items
- Resolved