Mojira Archive
MC-64087

Revengeful zombies / Zombie reinforcements will try to attack you in creative mode

What I expected to happen

Reinforcement zombies to not be hostile towards players in creative mode.

What actually happened

Reinforcement zombies try to attack the player who attacked the zombie spawning the reinforcement zombies even if the player is in creative mode.

Steps to reproduce

  1. Spawn 3 or more zombies close to each other, while in creative mode;
  2. Walk back a little, and switch to survival mode;
  3. Hit one zombie, and make sure they DON'T hurt you (important);
  4. Quickly switch to creative mode;
  5. Some zombies will be chasing you.

Steps to reproduce with commands

  1. Set your gamemode to Creative
  2. Set the difficulty to "Hard"
    /difficulty hard
    
  1. Set the gamerule doMobSpawning to true if it is not already
    /gamerule doMobSpawning true
    
  1. Set the time to "midnight" or make sure there is no light in the area around you
    /time set midnight
    
  1. Summon a zombie using the following command
    /summon minecraft:zombie ~ ~ ~ {Attributes:[{Base:1.0,Name:"zombie.spawn_reinforcements"}]}
    
  1. Hit the zombie a few times
  2. Search for the spawned reinforcement zombies, if there are no other zombies you can use the following command
    /execute as @e[type=zombie,sort=nearest,distance=..40] run data merge entity @s {Glowing:1b}
    

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

Either the method net.minecraft.entity.EntityLiving.setAttackTarget(EntityLivingBase) should not set players in Creative or Spectator mode as target or the method net.minecraft.entity.monster.EntityZombie.attackEntityFrom(DamageSource, float) should test if the player is in Creative mode.