Package net.minestom.server.event.entity
Class EntityDamageEvent
java.lang.Object
net.minestom.server.event.entity.EntityDamageEvent
- All Implemented Interfaces:
Event,CancellableEvent,EntityEvent,EntityInstanceEvent,InstanceEvent
Called with
LivingEntity.damage(DamageType, float).-
Constructor Summary
ConstructorsConstructorDescriptionEntityDamageEvent(@NotNull LivingEntity entity, @NotNull Damage damage, @Nullable SoundEvent sound) -
Method Summary
Modifier and TypeMethodDescription@NotNull DamageGets the damage type.@NotNull LivingEntityGets the entity of this event.@Nullable SoundEventgetSound()Gets the damage sound.booleanGets if theEventshould be cancelled or not.voidsetAnimation(boolean animation) Sets whether the damage animation should be played.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetSound(@Nullable SoundEvent sound) Changes the damage sound.booleanGets whether the damage animation should be played.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstance
-
Constructor Details
-
EntityDamageEvent
public EntityDamageEvent(@NotNull @NotNull LivingEntity entity, @NotNull @NotNull Damage damage, @Nullable @Nullable SoundEvent sound)
-
-
Method Details
-
getEntity
Description copied from interface:EntityEventGets the entity of this event.- Specified by:
getEntityin interfaceEntityEvent- Returns:
- the entity
-
getDamage
Gets the damage type.- Returns:
- the damage type
-
getSound
Gets the damage sound.- Returns:
- the damage sound
-
setSound
Changes the damage sound.- Parameters:
sound- the new damage sound
-
shouldAnimate
public boolean shouldAnimate()Gets whether the damage animation should be played.- Returns:
- true if the animation should be played
-
setAnimation
public void setAnimation(boolean animation) Sets whether the damage animation should be played.- Parameters:
animation- whether the animation should be played or not
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-