mojira.dev
MC-235353

Mobs do not retaliate against ghasts

The bug

Mobs do not retaliate against ghasts.

To reproduce

1. Summon a ghast

2. Summon any other hostile/neutral mob
3. Switch into survival mode
4. Let the ghast hit the mob
5. →❌  Observe. It still goes for you, not for the ghast.

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Comments 6

Code analysis (Mojang mappings, 22w12a):
This is a tentative analysis and might be incomplete, but I think that it explains the issue. Mobs are coded to not attack ghasts in Mob#canAttackType(EntityType):

@Override
    public boolean canAttackType(EntityType<?> $$0) {
        return $$0 != EntityType.GHAST;
    }

This method is called by some goals, such as NearestAttackableTargetGoal and HurtByTargetGoal (which is, as far as I can tell, used in retaliating), via TargetingConditions#test(...).

Note: this might be working as intended as per MC-120562.

@ampolive WAI as per jeb's comment on that bug report

However, jeb's comment is almost six years old. I don't see the harm in keeping this report open so that Mojang can decide whether this behavior is intended.

I don't think this is intended. If you read the comment that is linked in MC-120562 as the rationale for the resolution, it basically implies "because ghasts don't retaliate against other mobs, mobs shouldn't be aggressive towards ghasts", however, with that logic wolves shouldn't attack sheep because the sheep won't retaliate.

Further, I have noticed that this seems to be per-world. In certain worlds, mobs will be aggresive towards ghasts, whereas in others they will not. In my creative world I made a ghast farm that used iron golems to kill the ghasts and it worked perfectly fine, but in my survival world they will not attack the ghasts no matter what I do.

Definitely affects 1.20.1.

W_V

(Unassigned)

Confirmed

Mob behaviour

1.17.1, 21w39a, 21w40a, 1.18 Pre-release 1, 1.18, ..., 1.18.2, 22w12a, 1.19.2, 1.20.1, 1.21.8 Release Candidate 1

Retrieved