MinecraftConsoles/Minecraft.Server.FourKit/Event/Entity/EntityDeathEvent.cs
sylvessa f5f9aa1cf5 finish rewrite; port to cmake, loads of other changes
Theres documentation at https://sylvessa.zip/fourkit/ now. And a bunch of other changes. Check the discord server for a more comprehensive list
2026-03-21 14:01:49 -05:00

54 lines
1.8 KiB
C#

namespace Minecraft.Server.FourKit.Event.Entity;
using FourKitEntity = Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Inventory;
/// <summary>
/// Thrown whenever a LivingEntity dies.
/// </summary>
public class EntityDeathEvent : EntityEvent
{
private readonly List<ItemStack> _drops;
private int _droppedExp;
internal EntityDeathEvent(FourKitEntity.LivingEntity entity, List<ItemStack> drops)
: this(entity, drops, 0)
{
}
internal EntityDeathEvent(FourKitEntity.LivingEntity what, List<ItemStack> drops, int droppedExp)
: base(what)
{
_drops = drops;
_droppedExp = droppedExp;
}
/// <summary>
/// Returns the Entity involved in this event.
/// </summary>
/// <returns>Entity who is involved in this event.</returns>
public new FourKitEntity.LivingEntity getEntity() => (FourKitEntity.LivingEntity)entity;
/// <summary>
/// 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.
/// </summary>
/// <returns>Amount of EXP to drop.</returns>
public int getDroppedExp() => _droppedExp;
/// <summary>
/// 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.
/// </summary>
/// <param name="exp">Amount of EXP to drop.</param>
public void setDroppedExp(int exp) => _droppedExp = exp;
/// <summary>
/// Gets all the items which will drop when the entity dies.
/// </summary>
/// <returns>Items to drop when the entity dies.</returns>
public List<ItemStack> getDrops() => _drops;
}