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.

Attachments

Comments 1

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

[media]

Tis_awesomeness

(Unassigned)

Unconfirmed

26.4 Snapshot 4

Retrieved