mojira.dev
MC-260901

Guardians deal thorns damage even while their spikes are retracted

Guardians always deal thorns damage when attacked regardless of the state of their spines. Prior to 1.19.4 Pre-release 1, they only dealt thorns damage while their spines were extended.

Steps to Reproduce:

  1. Hit a guardian while its spines are retracted.

  2. Take damage anyway.

Comments 1

Code analysis (Mojang mappings, 1.19.4-rc2):
TL;DR: there is a missing check to see if the guardian is not moving in the new code.

The guardian's thorns damage doesn't actually check if the guardian's spikes are extended, but actually (used to) check when the guardian is moving. If the guardian is in water or on a bubble column, when it is moving, its spikes are retracted, and when it is not moving, its spikes are extended (see this.clientSideSpikesAnimation in Guardian#aiStep()), giving the illusion that this damage is actually related to the spikes.

Comparing Guardian#hurt(DamageSource, float). In 1.19.3:

...
    public boolean hurt(DamageSource $$0, float $$1) {
        if (!this.isMoving() && !$$0.isMagic() && $$0.getDirectEntity() instanceof LivingEntity) {
            LivingEntity $$2 = (LivingEntity)$$0.getDirectEntity();
            if (!$$0.isExplosion()) {
                $$2.hurt(DamageSource.thorns(this), 2.0f);
            }
        }
        ...
    }
...

In 1.19.4-rc2:

...
    public boolean hurt(DamageSource $$0, float $$1) {
        Entity bfh2;
        ...
        if (!$$0.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !$$0.is(DamageTypes.THORNS) && (bfh2 = $$0.getDirectEntity()) instanceof LivingEntity) {
            LivingEntity $$2 = (LivingEntity)bfh2;
            $$2.hurt(this.damageSources().thorns(this), 2.0f);
        }
        ...
    }
...

There is a missing check in the recent code to see if the guardian is not moving to apply the thorns damage. So, instead of

if (!$$0.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !$$0.is(DamageTypes.THORNS) && (bfh2 = $$0.getDirectEntity()) instanceof LivingEntity)

it should be:

if (!this.isMoving() && !$$0.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !$$0.is(DamageTypes.THORNS) && (bfh2 = $$0.getDirectEntity()) instanceof LivingEntity)

PencilSharpener

(Unassigned)

Confirmed

Mob behaviour

1.19.4 Release Candidate 2

1.19.4 Release Candidate 3

Retrieved