PlayerDeathEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PlayerDeathEvent : IEventA player died. The death message, inventory/experience drops and level keeping can be changed.
| Id | 112 |
| Key | mc:player_death |
| Cancellable | no |
| Fired by the engine | yes |
| Field | Type | Handlers may write | Description |
|---|---|---|---|
Player |
player |
no (readonly) | The player. |
Killer |
Entity |
no (readonly) | The entity responsible (none if there is none). |
Cause |
enum:DamageCause |
no (readonly) | The damage cause. |
DeathMessage |
component |
yes | Broadcast to everybody (empty = none). |
DropInventory |
bool |
yes | Drop the items (false keeps them, like keepInventory). Only the items: the experience is controlled by the two fields below. |
KeepLevel |
bool |
yes | Keep the experience level through the respawn (default: the keepInventory rule). True drops no experience orbs. |
DropExperience |
int |
yes | Experience points dropped as orbs at the death position (default the vanilla amount min(level*7, 100), 0 with keepInventory); independent of drop_inventory. |
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”public PlayerDeathEvent(Player player, Entity killer, DamageCause cause, Utf8String deathMessage, bool dropInventory, bool keepLevel, int dropExperience)Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.
Parameters
| Name | Type | Description |
|---|---|---|
player |
Player |
|
killer |
Entity |
|
cause |
DamageCause |
|
deathMessage |
Utf8String |
|
dropInventory |
bool |
|
keepLevel |
bool |
|
dropExperience |
int |
Properties
Section titled “Properties”| Member | Description |
|---|---|
DamageCause Cause { get; } |
The damage cause. |
Component DeathMessage { get; } |
Broadcast to everybody (empty = none). |
Utf8String DeathMessageJson { get; } |
Broadcast to everybody (empty = none). |
int DropExperience { get; set; } |
Experience points dropped as orbs at the death position (default the vanilla amount min(level*7, 100), 0 with keepInventory); independent of drop_inventory. |
bool DropInventory { get; set; } |
Drop the items (false keeps them, like keepInventory). |
bool KeepLevel { get; set; } |
Keep the experience level through the respawn (default: the keepInventory rule). |
Entity Killer { get; } |
The entity responsible (none if there is none). |
Player Player { get; } |
The player. |
static ushort CatalogueId { get; } |
Catalogue id (stable ABI). |
static bool IsCancellable { get; } |
Whether handlers can cancel the event. |
static string Key { get; } |
Registry key of the event. |
public DamageCause Cause { get; }The damage cause.
DeathMessage
Section titled “DeathMessage”public Component DeathMessage { get; }Broadcast to everybody (empty = none). (parsed on access; allocates).
DeathMessageJson
Section titled “DeathMessageJson”public Utf8String DeathMessageJson { get; }Broadcast to everybody (empty = none). as JSON text (borrowed).
DropExperience
Section titled “DropExperience”public int DropExperience { get; set; }Experience points dropped as orbs at the death position (default the vanilla amount min(level*7, 100), 0 with keepInventory); independent of drop_inventory.
DropInventory
Section titled “DropInventory”public bool DropInventory { get; set; }Drop the items (false keeps them, like keepInventory). Only the items: the experience is controlled by the two fields below.
KeepLevel
Section titled “KeepLevel”public bool KeepLevel { get; set; }Keep the experience level through the respawn (default: the keepInventory rule). True drops no experience orbs.
Killer
Section titled “Killer”public Entity Killer { get; }The entity responsible (none if there is none).
Player
Section titled “Player”public Player Player { get; }The player.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
Methods
Section titled “Methods”| Member | Description |
|---|---|
void SetDeathMessage(Component value) |
Replaces PlayerDeathEvent.DeathMessage; an empty component clears it where the event says so. |
SetDeathMessage
Section titled “SetDeathMessage”public void SetDeathMessage(Component value)Replaces PlayerDeathEvent.DeathMessage; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
See also
Section titled “See also”Component · DamageCause · Entity · IEvent · Player · Utf8String