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

A mob which is being targeted by a different mob, which is set as invulnerable after being targeted is still being targeted



    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.15.2
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows 10
    • Confirmation Status:


      I'll use a villager and zombie as an example here. If I spawn a villager and give it an Invulnerable tag with "/data modify entity @e[limit=1,type=minecraft:villager] Invulnerable set value 1", then it won't get attacked by a zombie I spawned after doing so. However if I spawn my villager, then spawn the zombie and let the zombie target my villager and then set the villager invulnerable it will attack my villager. It doesn't damage the villager or anything, but it will also not change to target any other villagers I spawned in after doing so which are mortal.

      Note that I disabled mob spawning in the world I was testing this in and also killed all entities. I did this to make sure that there are no other villagers / zombies suddenly affected by my commands.

      What I expected to happen was...:
      That my villager would not get attacked any longer after having it set as Invulnerable but that the zombie instead would have attacked other entities.

      What actually happened was...:
      The zombie kept on attacking my villager, which is not killable for the zombie.

      Steps to Reproduce:
      1. Create a new world
      2. Disable mob spawning by executing "/gamerule doMobSpawning false"
      3. Set the time to night to prevent the zombie from burning "/time set night"
      4. Kill all existing entities except the player "/kill @e[type=!minecraft:player]"
      5. Spawn a villager with a spawn egg
      6. Spawn a zombie with a spawn egg
      7. As soon as the zombie targets the villager run the command "/data modify entity @e[limit=1,type=minecraft:villager] Invulnerable set value 1"




            Unassigned Unassigned
            Thom Thom de M.
            0 Vote for this issue
            1 Start watching this issue