Class EntityDeathEvent

All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
PlayerDeathEvent

public class EntityDeathEvent extends EntityEvent implements Cancellable
Thrown whenever a LivingEntity dies
Since:
1.0.0
  • Constructor Details

  • Method Details

    • getEntity

      @NotNull public @NotNull LivingEntity getEntity()
      Description copied from class: EntityEvent
      Returns the Entity involved in this event
      Overrides:
      getEntity in class EntityEvent
      Returns:
      Entity who is involved in this event
      Since:
      1.1.0
    • getDamageSource

      @NotNull public @NotNull DamageSource getDamageSource()
      Gets the source of damage which caused the death.
      Returns:
      a DamageSource detailing the source of the damage for the death.
      Since:
      1.20.6
    • getDroppedExp

      public int getDroppedExp()
      Gets how much EXP should be dropped from this death.

      This does not indicate how much EXP should be taken from the entity in question, merely how much should be created after its death.

      Returns:
      Amount of EXP to drop.
      Since:
      1.0.0
    • setDroppedExp

      public void setDroppedExp(int exp)
      Sets how much EXP should be dropped from this death.

      This does not indicate how much EXP should be taken from the entity in question, merely how much should be created after its death.

      Parameters:
      exp - Amount of EXP to drop.
      Since:
      1.0.0
    • getDrops

      @NotNull public @NotNull List<ItemStack> getDrops()
      Gets all the items which will drop when the entity dies
      Returns:
      Items to drop when the entity dies
      Since:
      1.0.0
    • getReviveHealth

      public double getReviveHealth()
      Get the amount of health that the entity should revive with after cancelling the event. Set to the entity's max health by default.
      Returns:
      The amount of health
      Since:
      1.12.2
    • setReviveHealth

      public void setReviveHealth(double reviveHealth) throws IllegalArgumentException
      Set the amount of health that the entity should revive with after cancelling the event. Revive health value must be between 0 (exclusive) and the entity's max health (inclusive).
      Parameters:
      reviveHealth - The amount of health
      Throws:
      IllegalArgumentException - Thrown if the health is <= 0 or > max health
      Since:
      1.12.2
    • shouldPlayDeathSound

      public boolean shouldPlayDeathSound()
      Whether the death sound should play when the entity dies. If the event is cancelled it does not play!
      Returns:
      Whether the death sound should play. Event is called with this set to false if the entity is silent.
      Since:
      1.12.2
    • setShouldPlayDeathSound

      public void setShouldPlayDeathSound(boolean playDeathSound)
      Set whether the death sound should play when the entity dies. If the event is cancelled it does not play!
      Parameters:
      playDeathSound - Enable or disable the death sound
      Since:
      1.12.2
    • getDeathSound

      @Nullable public Sound getDeathSound()
      Get the sound that the entity makes when dying
      Returns:
      The sound that the entity makes
      Since:
      1.12.2
    • setDeathSound

      public void setDeathSound(@Nullable Sound sound)
      Set the sound that the entity makes when dying
      Parameters:
      sound - The sound that the entity should make when dying
      Since:
      1.12.2
    • getDeathSoundCategory

      @Nullable public SoundCategory getDeathSoundCategory()
      Get the sound category that the death sound should play in
      Returns:
      The sound category
      Since:
      1.12.2
    • setDeathSoundCategory

      public void setDeathSoundCategory(@Nullable SoundCategory soundCategory)
      Set the sound category that the death sound should play in.
      Parameters:
      soundCategory - The sound category
      Since:
      1.12.2
    • getDeathSoundVolume

      public float getDeathSoundVolume()
      Get the volume that the death sound will play at.
      Returns:
      The volume the death sound will play at
      Since:
      1.12.2
    • setDeathSoundVolume

      public void setDeathSoundVolume(float volume)
      Set the volume the death sound should play at. If the event is cancelled this will not play the sound!
      Parameters:
      volume - The volume the death sound should play at
      Since:
      1.12.2
    • getDeathSoundPitch

      public float getDeathSoundPitch()
      Get the pitch that the death sound will play with.
      Returns:
      The pitch the death sound will play with
      Since:
      1.12.2
    • setDeathSoundPitch

      public void setDeathSoundPitch(float pitch)
      Set the pitch that the death sound should play with.
      Parameters:
      pitch - The pitch the death sound should play with
      Since:
      1.12.2
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if this event is cancelled
      Since:
      1.12.2
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
      Since:
      1.12.2
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
      Since:
      1.1.0
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()
      Since:
      1.1.0