mojira.dev
MC-263303

Enderman automatically re-aggros just by being in their line of sight

In situations where an angered Enderman normally should stop being hostile towards the player, the Enderman instead continues being hostile, as long as the player is visible. The only way to turn them permanently neutral again is if the player dies.

The Enderman can turn temporarily neutral if the player is not in their line of sight when:

  1. The Enderman loses interest and teleports away due to daytime, or

  2. The player changes to creative mode

Normally, this should be "permanent". But due to the bug, as soon as the player is back in survival mode and in their line of sight, they automatically turn hostile without provoking them.

To reproduce

  1. Summon or find an Enderman.

  2. Set time to day, and gamemode to survival.

  3. Provoke the Enderman by looking at it or attacking it

  4. Enter a building where the Enderman doesn't have a line of sight to you (use glass blocks to see them becoming neutral again).

  5. Wait.

  6. Enderman loses interest, and is no longer hostile. (The stare sound also plays again - MC-216648).

  7. Leave the building.
    → The Enderman instantly sees you and is suddenly aggressive again without being provoked.

The issue in the code might be that the Enderman never forgets about the player even after becoming neutral, and only forgets if the player dies.

Possibly related to/caused by MC-197635 becoming fixed, which seems to be related to the fix of MC-188506 in the same snapshot.

Linked issues

Attachments

Comments 2

Related to MC-216648.

Based on my tests in 1.21.4, this actually affects all mobs that use the AngryAt and AngerTime tags, not just Endermen. This list includes Bees, Endermen, Iron Golems, Polar Bears, Wolves, and Zombified Piglins. There may be more, but these are the only mobs that are listed on the wiki as having the AngryAt tag. (The wiki claims that Piglins have it as well, but that is incorrect.)

When attacked or provoked, these mobs have their AngerTime set to 400–800 ticks, and AngryAt as the attacker. When the attacker is a Player, AngerTime remains static (excluding Bees; their timer always counts down) while the mob is chasing the Player. If the Player gets out of its range, or enters Creative mode, the mob typically returns to its neutral state, and AngerTime starts counting down at a rate of 20 per second. Should the Player return to Survival mode and enter the mob's detection range before AngerTime has reached zero, and AngryAt hasn't been changed to a different target, then the mob will re-engage with the player.

This differs to how mobs act when fighting other mobs. If, say, a Zombified Piglin and a Polar Bear are fighting, teleporting one 80 blocks away will have them cease hostilities, and have their AngerTime be immediately set to 0. Since AngerTime is set to 0, the two mobs will not resume their fight when reintroduced (unless they're normally hostile to each other, like Enderman and Endermites, or Wolves and Sheep).

Their AngerTime values also decrease while they fight, as opposed to staying constant like they do with the Player.

 

I also want to comment on steps 4–6 of your reproduction steps. I don't know if it's new, but Endermen will not lose interest by blocking their line of sight, and Endermen will only lose interest if it's daytime. You need to either make sure it's day, or just toggle your gamemode between Creative/Survival for a faster and more reliable process.

It can also be reproduced by dying outside of the attacker's detection range (I think? It may be a different value) and returning to the mob's location before its AngerTime decreases fully.

Jon1337

(Unassigned)

Confirmed

Gameplay

Normal

Mob behaviour

angered, angry, day, day-light, enderman, endermen, hostile, hostility, neutral-mob, time_of_day

1.19.4 Pre-release 4, 1.20, 1.20.1, 23w32a, 23w33a, ..., 1.20.4, 24w04a, 24w05b, 1.21.1, 24w33a

Retrieved