Interface ServerLivingEntityEvents.AllowDamage

Enclosing class:
ServerLivingEntityEvents
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface ServerLivingEntityEvents.AllowDamage
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    allowDamage(LivingEntity entity, DamageSource source, float amount)
    Called when a living entity is going to take damage.
  • Method Details

    • allowDamage

      boolean allowDamage(LivingEntity entity, DamageSource source, float amount)
      Called when a living entity is going to take damage. Can be used to cancel the damage entirely.

      The amount corresponds to the "incoming" damage amount, before armor and other mitigations have been applied.

      Parameters:
      entity - the entity
      source - the source of the damage
      amount - the amount of damage that the entity will take (before mitigations)
      Returns:
      true if the damage should go ahead, false to cancel the damage.