mojira.dev
MC-312599

Mobs cannot be immune to freezing and infested at the same time

Mobs that are immune to freezing and infested through datapacks will only be immune to infested.

To reproduce:

  1. Enable the attached datapack, adding chickens to the #immune_to_freezing and #immune_to_infested entity type tags.

  2. Spawn a chicken

  3. Splash the chicken with Freezing

  4. Wait

  5. 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

Attachments

Comments 2

Thank you for helping us improve Minecraft! We saved your files:

[media]

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.

Tis_awesomeness

(Unassigned)

Unconfirmed

26.4 Snapshot 4

Retrieved