diff --git a/src/main/java/net/minestom/server/entity/LivingEntity.java b/src/main/java/net/minestom/server/entity/LivingEntity.java index 6fa0534a3..bfb59c786 100644 --- a/src/main/java/net/minestom/server/entity/LivingEntity.java +++ b/src/main/java/net/minestom/server/entity/LivingEntity.java @@ -226,6 +226,22 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler { entityAnimationPacket.entityId = getEntityId(); entityAnimationPacket.animation = EntityAnimationPacket.Animation.TAKE_DAMAGE; sendPacketToViewersAndSelf(entityAnimationPacket); + + // Additional hearts support + if (this instanceof Player) { + Player player = (Player) this; + float additionalHearts = player.getAdditionalHearts(); + if (additionalHearts > 0) { + if (damage > additionalHearts) { + damage -= additionalHearts; + player.setAdditionalHearts(0); + } else { + player.setAdditionalHearts(additionalHearts - damage); + damage = 0; + } + } + } + setHealth(getHealth() - damage); // play damage sound diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 8ea70ef14..052fffb0d 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -252,6 +252,7 @@ public class Player extends LivingEntity { @Override public boolean damage(DamageType type, float value) { + // Compute final heart based on health and additional hearts boolean result = super.damage(type, value); if (result) { lastDamageSource = type;