Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-44283

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

XMLWordPrintable

    • 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

      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

      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.

        1. 2014-01-07_21.15.50.png
          2014-01-07_21.15.50.png
          46 kB
        2. 2014-01-07_21.15.28.png
          2014-01-07_21.15.28.png
          57 kB
        3. 2014-01-07_21.14.47.png
          2014-01-07_21.14.47.png
          50 kB
        4. 2014-01-07_21.14.39.png
          2014-01-07_21.14.39.png
          57 kB

            Unassigned Unassigned
            nyerguds Maarten Meuris
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: