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
is duplicated by 2
relates to 2
Attachments
Comments 11
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:
Can confirm in 20w48a.