Skip to content

Invulnerable

Marker component that prevents all damage to an entity. Stateless singleton.

// check if entity is invulnerable
boolean isInvulnerable = store.getComponent(ref, Invulnerable.getComponentType()) != null;
// or via archetype check (more efficient in systems)
boolean isInvulnerable = archetype.contains(Invulnerable.getComponentType());
// make entity invulnerable
store.ensureComponent(ref, Invulnerable.getComponentType());
// remove invulnerability
store.tryRemoveComponent(ref, Invulnerable.getComponentType());

For entity holders:

Holder<EntityStore> holder = EntityStore.REGISTRY.newHolder();
holder.ensureComponent(Invulnerable.getComponentType());

The DamageSystems.FilterUnkillable system checks for this component during the damage pipeline before applying damage:

boolean invulnerable = archetype.contains(Invulnerable.getComponentType());
if (invulnerable) {
damage.setCancelled(true);
}

Invulnerable entities are also:

  • Excluded from AOE damage targeting
  • Excluded from attack target selection (VulnerableMatcher)
  • Able to breathe in any material (no drowning)
ContextBehavior
Creative modeAutomatically added when entering, removed when leaving
NPCs with invulnerable rolesSet via Role configuration
DeployablesSet via DeployableConfig.getInvulnerable()
/entity invulnerable commandToggles on target entity

Entities can also be temporarily invulnerable through status effects:

EffectControllerComponent effects = store.getComponent(ref, EffectControllerComponent.getComponentType());
if (effects != null && effects.isInvulnerable()) {
// temporarily invulnerable via effect
}

This is checked alongside the component in the damage filter stage.

The component state is synced to clients via ComponentUpdateType.Invulnerable, allowing UI/targeting systems to know which entities can be damaged.

ComponentEffect
InvulnerableBlocks damage, still has collision
IntangibleNo collision, also blocks damage

Use Invulnerable when you want the entity to still participate in physics but not take damage (e.g., creative mode players).

Use Intangible when the entity should have no physical presence (e.g., markers, visual effects).