Link Search Menu Expand Document

Invulnerable Entities

Beginner

Using Damage Sensor:

"minecraft:damage_sensor": {
    "triggers": {
    "on_damage": {
        "filters": {}
    },
    "deals_damage": false
        }
}

With High Health:

"minecraft:health": {
    "value": 800,
    "max": 800
}

Filtering Damage:

Using minecraft:damage_sensor, you can create some very nice damage-filtering. For example, only being invincible to lighting, or only taking damage from players.

The best way to learn about this component is by using the vanilla examples for damage sensor.

Filtering Damage Example:

"minecraft:lightning_immune": {
    "minecraft:damage_sensor": {
        "triggers": {
            "on_damage": {
                "filters": {
                    "test": "is_family",
                    "subject": "other",
                    "value": "lightning"
                }
            },
            "deals_damage": false
        }
    }
}