WorldTestContext and adds NPC-specific operations through NPCTestAdapter and NPCAssert.
NPCs are the living inhabitants of Hytale - Kweebecs, Trork Warriors, Outlander Hunters, and any custom roles your mod defines. Testing NPCs is about verifying that the right creatures spawn with the right properties and behave as expected.
NPC role names like
Trork_Warrior and Kweebec_Sapling are examples from Hytale’s default content. Your mod’s NPCs will have their own role names. If a role name is not recognized, spawnEntity falls back to creating an empty entity with a TransformComponent. Use spawnNPC when you need to guarantee the NPC type is correct - it throws an error if the role is invalid.spawnEntity vs spawnNPC
Understanding the difference between these two methods is important:ctx.spawnEntity("Kweebec_Sapling", x, y, z)- Attempts to spawn via NPCPlugin first. If it fails, falls back to creating an empty entity with no components. The empty entity will have no health, no AI, and no model. This silent fallback can make tests pass when they should fail.ctx.spawnNPC("Kweebec_Sapling", x, y, z)- Directly calls NPCPlugin to spawn a fully initialized NPC. If the role name is not recognized, it fails explicitly rather than silently creating an empty entity. This is the preferred method for NPC tests.
spawnNPC when you need a real NPC with health, AI, and model components. Use spawnEntity only when you intentionally want the fallback behavior for generic entity testing.
Complete Example Suite
Adapter Methods
Assertion Methods
NPC Role Names
NPC role names in Hytale use PascalCase with underscores to separate words. Common built-in roles include:Kweebec_Sapling- Friendly forest creatureTrork_Warrior- Hostile undead melee combatantOutlander_Hunter- Ranged hostile NPC
Next Steps
- Stats & Combat - verify NPC health and damage
- AI and Pathfinding - inspect NPC AI state
- World Testing - entity positioning and world operations