Class EntityDamageEvent

java.lang.Object
fr.fidorial.event.entity.EntityDamageEvent
All Implemented Interfaces:
Cancellable, Event

public class EntityDamageEvent extends Object implements Event, Cancellable
Fired before an entity takes damage, once invulnerability frames have been cleared but before armor, absorption and knockback are applied.
Since:
0.1.0
  • Constructor Details

    • EntityDamageEvent

      public EntityDamageEvent(LivingEntity entity, DamageSource source, float damage, double knockback)
  • Method Details

    • entity

      public LivingEntity entity()
    • source

      public DamageSource source()
      Returns:
      the origin of the hit, carrying the damage type and the entities involved
    • damager

      public @Nullable Entity damager()
      Returns:
      the entity that caused the damage, or null for environmental damage
    • damage

      public float damage()
      Returns:
      the damage about to be dealt, in half-hearts, before armor and absorption
    • setDamage

      public void setDamage(float damage)
      Parameters:
      damage - the damage to deal instead; <= 0 makes the hit harmless
    • knockback

      public double knockback()
      Returns:
      the horizontal knockback strength about to be applied
    • setKnockback

      public void setKnockback(double knockback)
      Parameters:
      knockback - the knockback strength to apply instead; 0 disables it
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface Cancellable