namespace Minecraft.Server.FourKit.Event.Entity;
using FourKitEntity = Minecraft.Server.FourKit.Entity;
///
/// Stores data for damage events.
///
public class EntityDamageEvent : EntityEvent, Cancellable
{
///
/// An enum to specify the cause of the damage.
///
public enum DamageCause
{
/// Damage caused by being in the area when a block explodes.
BLOCK_EXPLOSION,
/// Damage caused when an entity contacts a block such as a Cactus.
CONTACT,
/// Custom damage.
CUSTOM,
/// Damage caused by running out of air while in water.
DROWNING,
/// Damage caused when an entity attacks another entity.
ENTITY_ATTACK,
/// Damage caused by being in the area when an entity, such as a Creeper, explodes.
ENTITY_EXPLOSION,
/// Damage caused when an entity falls a distance greater than 3 blocks.
FALL,
/// Damage caused by being hit by a falling block which deals damage.
FALLING_BLOCK,
/// Damage caused by direct exposure to fire.
FIRE,
/// Damage caused due to burns caused by fire.
FIRE_TICK,
/// Damage caused by direct exposure to lava.
LAVA,
/// Damage caused by being struck by lightning.
LIGHTNING,
/// Damage caused by being hit by a damage potion or spell.
MAGIC,
/// Damage caused due to a snowman melting.
MELTING,
/// Damage caused due to an ongoing poison effect.
POISON,
/// Damage caused when attacked by a projectile.
PROJECTILE,
/// Damage caused by starving due to having an empty hunger bar.
STARVATION,
/// Damage caused by being put in a block.
SUFFOCATION,
/// Damage caused by committing suicide using the command "/kill".
SUICIDE,
/// Damage caused in retaliation to another attack by the Thorns enchantment.
THORNS,
/// Damage caused by falling into the void.
VOID,
/// Damage caused by Wither potion effect.
WITHER,
}
private readonly DamageCause _cause;
private double _damage;
private readonly double _finalDamage;
private bool _cancel;
internal EntityDamageEvent(FourKitEntity.Entity damagee, DamageCause cause, double damage)
: base(damagee)
{
_cause = cause;
_damage = damage;
_finalDamage = damage;
_cancel = false;
}
///
/// Gets the cause of the damage.
///
/// A value detailing the cause of the damage.
public DamageCause getCause() => _cause;
///
/// Gets the raw amount of damage caused by the event.
///
/// The raw amount of damage.
public double getDamage() => _damage;
///
/// Gets the amount of damage caused by the event after all damage
/// reduction is applied.
///
/// The amount of damage after reduction.
public double getFinalDamage() => _finalDamage;
///
public bool isCancelled() => _cancel;
///
public void setCancelled(bool cancel)
{
_cancel = cancel;
}
///
/// Sets the raw amount of damage caused by the event.
///
/// The raw amount of damage.
public void setDamage(double damage)
{
_damage = damage;
}
}