Invulnerable
Marker component that prevents all damage to an entity. Stateless singleton.
Access
Section titled “Access”// check if entity is invulnerableboolean isInvulnerable = store.getComponent(ref, Invulnerable.getComponentType()) != null;
// or via archetype check (more efficient in systems)boolean isInvulnerable = archetype.contains(Invulnerable.getComponentType());Adding/Removing
Section titled “Adding/Removing”// make entity invulnerablestore.ensureComponent(ref, Invulnerable.getComponentType());
// remove invulnerabilitystore.tryRemoveComponent(ref, Invulnerable.getComponentType());For entity holders:
Holder<EntityStore> holder = EntityStore.REGISTRY.newHolder();holder.ensureComponent(Invulnerable.getComponentType());How It Works
Section titled “How It Works”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)
Built-in Usage
Section titled “Built-in Usage”| Context | Behavior |
|---|---|
| Creative mode | Automatically added when entering, removed when leaving |
| NPCs with invulnerable roles | Set via Role configuration |
| Deployables | Set via DeployableConfig.getInvulnerable() |
/entity invulnerable command | Toggles on target entity |
Effect-Based Invulnerability
Section titled “Effect-Based Invulnerability”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.
Network Sync
Section titled “Network Sync”The component state is synced to clients via ComponentUpdateType.Invulnerable, allowing UI/targeting systems to know which entities can be damaged.
vs Intangible
Section titled “vs Intangible”| Component | Effect |
|---|---|
Invulnerable | Blocks damage, still has collision |
Intangible | No 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).