mojira.dev
MC-199210

Lava can't destroy armor stands

The bug

Armor stands don't receive damage in lava, instead, they catch fire and are destroyed a few seconds after leaving lava.

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 11

Can confirm in 20w48a.

Confirm in 20w49a, 20w51a

Can confirm in 21w03a.

Can confirm in 21w08b. Video attached.

Can confirm in 21w11a.

1 more comments

Can confirm in 1.17.1.

Can confirm in 1.18.

Can Confirm for 22w05a
Code Analysis - Yarn 22w05a

net.minecraft.entity.decoration.ArmorStandEntity.java

public boolean damage(DamageSource source, float amount) {
    if (!this.world.isClient && !this.isRemoved()) {
        if (DamageSource.OUT_OF_WORLD.equals(source)) {
            this.kill();
        } else if (!this.isInvulnerableTo(source) && !this.invisible && !this.isMarker()) {
            if (source.isExplosive()) {
                this.onBreak(source);
                this.kill();
            } else if (DamageSource.IN_FIRE.equals(source)) {
                if (this.isOnFire()) {
                    this.updateHealth(source, 0.15F);
                } else {
                    this.setOnFireFor(5);
                }
            } else if (DamageSource.ON_FIRE.equals(source) && this.getHealth() > 0.5F) {
                this.updateHealth(source, 4.0F);
            } else {
                boolean isProj = source.getSource() instanceof PersistentProjectileEntity proj;
                boolean hasPiercing = isProj && proj.getPierceLevel() > 0;
                boolean fromPlayer = "player".equals(source.getName());
                if (!fromPlayer && !isProj) { //Will always be true for lava damage
                    return false;
		} //elseif, etc... there's a return true in here
            }
        }
    }
    return false;
}

As you can see above, when lava damages an entity the damage source is DamageSource.LAVA. Although no check for lava is done. Then the only checks after that will ignore the lava damage since it's not a projectile & it's not from a player.

The Fix:
This is very simple, just add a lava check. You can do this by simply adding it to the ON_FIRE check

} else if (DamageSource.LAVA.equals(source) || (DamageSource.ON_FIRE.equals(source) && this.getHealth() > 0.5F)) {
    this.updateHealth(source, 4.0F);
}

I would prefer using the amount variable for the second argument. Although lava damage does do 4 damage and you seem to be using a static number for the others, so ill just copy it over. :shrug:

Working Fix

Can confirm in 1.19.2.

Why exactly was this bug marked as "Works as intended" ?

Muchan

(Unassigned)

Confirmed

Entities

1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4, 20w46a, ..., 22w05a, 1.18.2, 22w14a, 1.19.2, 1.19.4 Pre-release 1

Retrieved