Mojira Archive
MC-110386

Certain mobs attack themselves when targeted by a mob of the same type

The bug

If a zombie is provoked by a second zombie using commands, the second zombie will join in the fight against itself, causing it to attack itself repeatedly.

Originally reported by malon. See also this discussion on Reddit.

Affected mobs

Bees, blazes, endermites, husks, pandas, ravagers, silverfish, witches, wolves, zombies, zombie villagers, zombified piglins.

How to reproduce

  1. Summon two zombies that cannot move, with unbreakable helmets for sun protection:
    /summon minecraft:zombie ~-2 ~ ~ {Tags:["z1"],CustomName:"z1",CustomNameVisible:1b,ArmorItems:[{},{},{},{id:"minecraft:leather_helmet",components:{"minecraft:unbreakable":{}}}],attributes:[{id:"minecraft:generic.movement_speed",base:0d}]}
    /summon minecraft:zombie ~2 ~ ~ {Tags:["z2"],CustomName:"z2",CustomNameVisible:1b,ArmorItems:[{},{},{},{id:"minecraft:leather_helmet",components:{"minecraft:unbreakable":{}}}],attributes:[{id:"minecraft:generic.movement_speed",base:0d}]}
  2. Have the first zombie provoke the second zombie:
    /damage @n[type=zombie,tag=z2] 0 minecraft:mob_attack by @n[type=zombie,tag=z1]

    The first zombie begins to attack itself

Code analysis

Code analysis can be found in this comment.