Mobs with multiple entity type tags corresponding to effect immunity only respect one. This issue can be observed in 26.3 using datapacks, and can also be observed without datapacks in 26.4 Snapshot 3 & Snapshot 4, where Strays are now affected by Poison and Regeneration.
26.4 Snapshot 4 overview
Review the following method in LivingEntity.class:
public boolean canBeAffected(final MobEffectInstance newEffect) {
if (this.is(EntityTypeTags.IMMUNE_TO_INFESTED)) {
return !newEffect.is(MobEffects.INFESTED);
} else if (this.is(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) {
return !newEffect.is(MobEffects.FREEZING);
} else if (this.is(EntityTypeTags.IMMUNE_TO_OOZING)) {
return !newEffect.is(MobEffects.OOZING);
} else {
return !this.is(EntityTypeTags.IGNORES_POISON_AND_REGEN) ? true : !newEffect.is(MobEffects.REGENERATION) && !newEffect.is(MobEffects.POISON);
}
}It takes no great effort to see the problem: mobs which have multiple entity type tags granting them immunity to specific effects will only check the if clause of the first such tag. The logic of this method is backwards. It should be (I’ve also reordered the list so that it is alphabetical):
public boolean canBeAffected(final MobEffectInstance newEffect) {
if (newEffect.is(MobEffects.FREEZING)) {
return !this.is(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES);
} else if (newEffects.is(MobEffects.INFESTED)) {
return !this.is(EntityTypeTags.IMMUNE_TO_INFESTED);
} else if (newEffects.is(MobEffects.OOZING)) {
return !this.is(EntityTypeTags.IMMUNE_TO_OOZING);
} else if (newEffects.is(MobEffects.POISON) || newEffects.is(MobEffects.REGENERATION)) {
return !this.is(EntityTypeTags.IGNORES_POISON_AND_REGEN);
}
return true;
}Impact on 26.3
In 26.3, Freezing does not yet exist, so no mobs have multiple of these tags by default. Reproducing the issue therefore requires a datapack:
Enable the attached datapack, which adds chickens to the
#immune_to_oozingand#immune_to_infestedentity type tagsSpawn a chicken
Enable
looking_at_entity_tagsin debug options and confirm that the chicken you spawned has theminecraft:immune_to_oozingtagSplash the chicken with Oozing
Kill the chicken
❌ Slimes spawn even though chickens are immune to Oozing through the datapack
Linked issues
is duplicated by 1
Attachments
Comments 0
No comments.