Mobs that are immune to freezing and infested through datapacks will only be immune to infested.
To reproduce:
Enable the attached datapack, adding chickens to the
#immune_to_freezingand#immune_to_infestedentity type tags.Spawn a chicken
Splash the chicken with Freezing
Wait
Note that the chicken does not take freezing damage as expected
Code analysis:
LivingEntity.class
public boolean canBeAffected(MobEffectInstance newEffect) {
if (getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) {
return !newEffect.is(MobEffects.INFESTED);
} else if (getType().is(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) {
return !newEffect.is(MobEffects.FREEZING);
} else if (getType().is(EntityTypeTags.IMMUNE_TO_OOZING)) {
return !newEffect.is(MobEffects.OOZING);
} else if (getType().is(EntityTypeTags.IGNORES_POISON_AND_REGEN)) {
return !newEffect.is(MobEffects.REGENERATION) && !mobEffectInstance.is(MobEffects.POISON);
} else {
return true;
}
}If the entity is in the #immune_to_infested tag, the code only checks if the applied status effect is infested, and does not check whether the entity is also immune to other effects.
Linked issues
duplicates 1
Attachments
Comments 2
I’m just going to resolve this into MC-270793 and request a retriage on that report once I’ve touched it up, it is not necessary to make a separate report for every combination of effects when the cause (method logic is backwards) is a simple and easy fix. Also the provided datapack is incorrect, immune_to_freezing.json should be freeze_immune_entity_types.json, and your description here does not correctly identify the issue (chicken should not even have the effect, even though with the fixed filename it does not take damage from freezing). Much more salient issue which I will mention in MC-270793: strays are now affected by poison and regen with no datapacks.
Thank you for helping us improve Minecraft! We saved your files: