mojira.dev
MC-169556

Vindicator named "Johnny" doesn't attack ghast

The bug

Vindicators named "Johnny" don't attack ghasts.

Expected Result

Vindicators named "Johnny" would attack ghasts, as they attack every other living entity except armor stands (and baby villagers).

How to reproduce

/summon minecraft:ghast ~10 ~3 ~ {NoAI:1b,Silent:1b}
/summon minecraft:vindicator ~ ~ ~ {Johnny:1b}

Code analysis

Code analysis can be found in this comment.

Linked issues

Attachments

Comments 14

Can confirm in 20w51a.

Can confirm in 21w03a.

Can confirm in 1.16.5 and 21w08b.

Can confirm in 21w13a.

Can confirm in 21w17a

4 more comments

Can confirm in 1.18.2 and 22w12a. You can use the following commands to reproduce this issue.

/summon minecraft:ghast ~10 ~3 ~ {NoAI:1b,Silent:1b}
/summon minecraft:vindicator ~ ~ ~ {Johnny:1b}

Code analysis (Mojang mappings, 22w12a):
This is a tentative analysis, but it seems very reasonable by having looked at the code.

The code for Johnny vindicator attacking is found in Vindicator.VindicatorJohnnyAttackGoal, which extends NearestAttackableTargetGoal<LivingEntity>. In NearestAttackableTargetGoal#canUse(...), the function findTarget(...) is called, which uses EntityGetter#getNearestEntity(...). This takes the mob's targeting conditions (this.targetConditions) as a parameter and tests them by calling TargetingConditions#test(...). If the test fails, the entity is not returned.

In TargetingConditions#test(...), there is the following code:

Mob $$5;
            if (this.isCombat && (!$$0.canAttack($$1) || !$$0.canAttackType($$1.getType()) || $$0.isAlliedTo($$1))) {
                return false;
            }

So the test fails, specifically, if canAttackType(EntityType) returns false. If we look at Mob#canAttackType(EntityType):

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

This returns false if the entity is a ghast. As the target entity would be a ghast, the test fails, so the vindicator cannot attack ghasts. This might also be the cause of MC-235353, but I am not sure.

Oh yeah, it definitely is the same cause. Mobs in general cannot target ghasts.

Can confirm in 1.19.

Can confirm in 1.19.2.

Block_chenfeng

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour

Johnny-vindicator

1.15.1, 1.16.2, 20w51a, 21w03a, 1.16.5, ..., 22w12a, 1.19, 1.19.1, 1.19.2, 1.21.4

Retrieved