When an entity dies in Hytale, theDocumentation Index
Fetch the complete documentation index at: https://docs.hrtk.frotty27.com/llms.txt
Use this file to discover all available pages before exploring further.
DeathComponent is attached to it carrying the cause of death, the death message, item loss data, and respawn control. Your death screen, kill feed, item recovery system, and custom respawn logic all depend on reading this component correctly.
Testing death and respawn is critical because getDeathCause() returns a DamageCause index, not the DamageCause object itself. If you read it wrong, your kill feed shows “Unknown” for every death. Automated tests catch this before your players do.
Death assertions require entities with stat components (EntityStatMap, DeathComponent). Always use
spawnNPC with a valid role name - empty entities created with ctx.createEntity() lack the required components.Complete Example Suite
DeathComponent API
TheDeathComponent is the ECS component Hytale attaches to dead entities. Key methods:
| Method | Returns | Description |
|---|---|---|
getDeathCause() | death cause info | The damage cause that killed the entity |
getDeathMessage() | String | The death message for the kill feed |
setDeathMessage(String) | void | Override the death message |
isShowDeathMenu() | boolean | Whether to show the death/respawn UI |
setShowDeathMenu(boolean) | void | Control death menu visibility |
getItemsLostOnDeath() | items | Items the entity drops on death |
setItemsLostOnDeath(...) | void | Override dropped items |
getDeathItemLoss() | DeathItemLoss | Item loss configuration |
respawn() | void | Static method to trigger respawn |
DeathItemLoss API
DeathItemLoss controls what items a player loses when they die:
| Method | Returns | Description |
|---|---|---|
getLossMode() | loss mode | How items are lost (all, percentage, none) |
getItemsLost() | items | Which items are marked for loss |
getAmountLossPercentage() | float | Percentage of stack amounts lost |
getDurabilityLossPercentage() | float | Percentage of durability lost |
noLossMode() | DeathItemLoss | Static factory for zero item loss |
DamageSystems Pipeline
UseDamageSystems.executeDamage() instead of manually subtracting health. The damage pipeline runs resistances, triggers events, and processes death correctly:
DamageModule.get()- returns the singletonDamageModule.getGatherDamageGroup()- first stage, collects damage sourcesDamageModule.getFilterDamageGroup()- second stage, applies resistancesDamageModule.getInspectDamageGroup()- final stage, logs and triggers events
Isolation Recommendation
Death tests mutate entity state heavily. UseIsolationStrategy.DEDICATED_WORLD:
Next Steps
- Stats & Combat - health, damage, and stat modifier assertions
- Effects - invulnerability and status effect testing
- Inventory & Loot - verify item drops on death