EffectControllerComponent. HRTK’s EffectAssert class lets you verify which effects are present, count active effects, and check invulnerability state.
Status effects are a critical part of game balance - poison, speed boosts, shields, and invulnerability all change how entities interact with the world. Testing effects ensures that your mod applies the right effects at the right time, that effects stack correctly, and that removal works cleanly.
Effect assertions require entities with an EffectControllerComponent. Not all entity types have this component. Use
spawnNPC with a role name that includes effects, or check for the component before asserting.Important: Empty Entities Lack EffectControllerComponent
A common pitfall when testing effects is using a bare entity created withctx.createEntity(). Empty entities have no components at all, including no EffectControllerComponent. If you try to assert on effects for an empty entity, the assertion will fail because there is no controller to inspect.
Always spawn a fully initialized NPC using ctx.spawnNPC(...) when testing effects. NPC entities come with the EffectControllerComponent pre-attached as part of their standard component set.
Complete Example Suite
EffectAssert Methods
| Method | Description |
|---|---|
assertHasEffect(store, ref, effectIndex) | Assert entity has the effect at the given index |
assertNoEffect(store, ref, effectIndex) | Assert entity does NOT have the effect |
assertEffectCount(store, ref, expected) | Assert the number of active effects |
assertInvulnerable(store, ref) | Assert entity is invulnerable |
How It Works
EffectAssert locates the EffectControllerComponent on the entity via reflection, then calls:
hasEffect(int index)to check for specific effectsgetActiveEffects()to count active effectsisInvulnerable()for invulnerability checks
Effect indices are integer identifiers used by Hytale’s effect system. The specific index values depend on your game content and mod configuration. Define constants in your test suite for readability, as shown in the example above.
Hytale Effect System API
Beyond the HRTK wrappers, the Hytale server exposes these key effect classes directly:EffectControllerComponent- The ECS component on entities that manages all active effects. HasaddEffect(),addInfiniteEffect(),removeEffect(),clearEffects(),isInvulnerable(),setInvulnerable(),getAllActiveEntityEffects().ActiveEntityEffect- Represents a running effect instance. HasgetRemainingDuration(),isInfinite(),isDebuff(),isInvulnerable().EntityEffect(asset) - The static effect definition loaded from content. HasgetDuration(),getOverlapBehavior(),getStatModifiers(),isDebuff(),isInfinite().OverlapBehavior(enum) -EXTEND,OVERWRITE,IGNORE. Controls what happens when the same effect is applied twice.
Duration and Debuff Considerations
Effects in Hytale typically have a duration (measured in ticks). When testing timed effects:- Apply the effect, then call
ctx.waitTicks(n)to advance time - If the effect duration is shorter than your wait, the effect will have expired
- Use
assertNoEffectafter waiting to verify that timed effects expire correctly - Debuffs (like poison) deal damage over time, so combine with
StatsAssert.assertAlive()to verify the entity survives the debuff duration
Recommended Isolation
Effect tests modify entity state. UseIsolationStrategy.DEDICATED_WORLD:
Next Steps
- Stats & Combat - health and stat modifier assertions
- Inventory & Loot - item and drop testing
- World Testing - entity spawning and positioning