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:
DeathItemLoss API
DeathItemLoss controls what items a player loses when they die:
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