mojira.dev
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.

Linked issues

MC-48703 Social spawned zombie will pathfind to you even in creative Resolved MC-50868 Social zombies go after players in creative mode Resolved MC-75400 Zombie reinforcements are hostile to creative players Resolved MC-75826 Zombie from Reinforcements becomes hostile Resolved MC-87583 Reinforcement Zombie follows Creative Player Resolved

Attachments

Comments 28

Regressed in 1.8 release. To reproduce (I think):
Spawn zombies behind you (20-30 blocks away)
Spawn zombies in front of you, go into survival and quickly punch them, and go back into Creative.
Hitting the zombie/other zombies or going into Spectator does not fix the issue, but logging out/back in does.

18 more comments

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

Can confirm in 1.21.4.

Luís Alves

marcono1234

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour

attack, reinforcement, zombie

Minecraft 14w30c, Minecraft 14w31a, Minecraft 14w32a, Minecraft 1.8, Minecraft 1.8.1, ..., 1.19.2, 1.19.3, 23w06a, 1.20.1, 1.20.4

Minecraft 14w32d

Retrieved