Class EntityDamageEvent
java.lang.Object
fr.fidorial.event.entity.EntityDamageEvent
- All Implemented Interfaces:
Cancellable, Event
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 Summary
ConstructorsConstructorDescriptionEntityDamageEvent(LivingEntity entity, DamageSource source, float damage, double knockback) Creates an event. -
Method Summary
Modifier and TypeMethodDescriptionfloatdamage()damager()entity()Returns the entity about to be hurt.booleanReturnstrueif the action this event describes will not happen.doublevoidsetCancelled(boolean cancelled) Prevents or re-allows the action this event describes.voidsetDamage(float damage) voidsetKnockback(double knockback) source()
-
Constructor Details
-
EntityDamageEvent
Creates an event.- Parameters:
entity- the entity about to be hurtsource- the origin of the hitdamage- the damage about to be dealt, in half-heartsknockback- the horizontal knockback strength about to be applied- Since:
- 0.1.0
-
-
Method Details
-
entity
Returns the entity about to be hurt.- Returns:
- the entity about to be hurt
- Since:
- 0.1.0
-
source
- Returns:
- the origin of the hit, carrying the damage type and the entities involved
-
damager
-
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;<= 0makes 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;0disables it
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableReturnstrueif the action this event describes will not happen.- Specified by:
isCancelledin interfaceCancellable- Returns:
trueif the action this event describes will not happen
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:CancellablePrevents or re-allows the action this event describes.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancelled-trueto prevent it
-