mojira.dev
MC-63714

Zombified piglins get angry when hit in creative mode

The bug

Zombified Piglins (Zombie Pigmen) get angry when hit in Creative mode and remain angry when switching to Survival mode afterwards.

Expected would be that hitting a Zombified Piglin in Creative mode should not make them angry.

Reproduction steps

  1. Spawn a Zombified Piglin

  2. If not already, change to Survival or Adventure mode
    :info: The Zombified Piglin does not attack you

  3. Switch to Creative, and hit the Zombified Piglin

  4. Switch back to Survival or Adventure (e.g. using F3 + F4)
    ❌ Now the Zombified Piglin attacks you, even though you were in Creative mode when you hit it

Code analysis

See this comment (likely outdated).

Linked issues

Attachments

Comments 18

Confirmed in 1.8.2-pre5.

Confirmed in 15w31b.

EDIT: In fact, I'm now having pigmen attack while in Creative and Spectator. It happens if I aggro them, get out of range, then come back in Creative mode.

ProfMobius (Thomas Guimbretiere)

This is both fixed/couldn't reproduce.

I think this got fixed automatically when I fixed the aggro behavior while in creative for the wolves.

Not fixed for 16w02a

Please link to this comment in the description

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

Affects probably all mobs, for example also Endermen. Punching one in Creative mode and switching to Survival mode causes the Enderman to become aggressive even if you did not stare at it.

It looks like the reason for this is, that the following methods do not test if the entity is a valid target, which is for example not the case if the player is in creative mode:

  • net.minecraft.entity.EntityLivingBase.setRevengeTarget(EntityLivingBase)

  • net.minecraft.entity.EntityLiving.setAttackTarget(EntityLivingBase)

  • net.minecraft.entity.monster.EntityPigZombie.setRevengeTarget(EntityLivingBase)

  • net.minecraft.entity.monster.EntityPigZombie.becomeAngryAt(Entity)

Note: The method net.minecraft.entity.ai.EntityAITarget.isSuitableTarget(EntityLiving, EntityLivingBase, boolean, boolean) does some tests, maybe it could be used in some way.

8 more comments

Oh, okay.

I actually found out this happens with more than just zombified piglins... Maybe time to create a new report...

Yes please create a separate report then (and refer to this one). Additionally if it turns out that for these mobs the bug was fixed / did not exist in 1.16-pre1, but started appearing in a newer version then we will likely resolve this report here and only keep your report open instead.

@@unknown → MC-199589

Thanks @unknown. I have reverted some of the changes I made to this report and resolve it as "Fixed" again because the issue was indeed fixed in 1.16-pre1.
The new report is MC-199589 which covers all kind of mobs which are passive by default (or don't attack the player because they are invisible) and are now affected by this bug.

eandr127

(Unassigned)

Confirmed

Minecraft 1.7.10, Minecraft 14w30c, Minecraft 14w31a, Minecraft 14w32b, Minecraft 14w32d, ..., 19w39a, 19w41a, 1.15, 1.15.2, 20w15a

Minecraft 16w02a, Minecraft 18w15a, 1.16 Pre-release 1

Retrieved