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

Mob item pick up behavior is not distinct resulting in mobs constantly dropping and picking up items

XMLWordPrintable

    • Confirmed
    • (Unassigned)

      The bug

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      The rules for when a mob which can pick up items should pick up items are currently (method net.minecraft.entity.EntityLiving.updateEquipmentIfNeeded(EntityItem)):

      (itemToCheck.getDamage() < itemEquipped.getDamage()) OR (itemToCheck.hasTagCompound() AND NOT(itemEquipped.hasTagCompound()))
      

      Note: This shows the pseudo code with the fix for MC-44283.

      The problem here is that if the mob has a less damaged item equipped but the item to pick up has NBT data it will swap the equipped item. However, after that the item to pick up is less damaged and therefor the mob swaps them items again and so on.

      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 an undamaged chestplate at the mob
        /give @p diamond_chestplate
        
      4. Throw a damaged chestplate (with NBT) at the mob
        /give @p diamond_chestplate{Enchantments:[{id:unbreaking,lvl:1s}],Damage:1}
        

        The mob constantly swaps the items

      Note: Because of MC-44283 the item in step 3 has to be nearly broken while the item in step 4 has to be slightly damaged.

            Unassigned Unassigned
            marcono1234 Marcono1234
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: