Entity Documentation - minecraft:damage_sensor

minecraft:damage_sensor defines what events to call when this entity is damaged by specific entities or items.

Parameters

Name Default Value Type Description
List triggers List of triggers with the events to call when taking specific kinds of damage.

triggers

triggers is a list that is defined by six parameters. Each item has the following properties:

Name Default Value Type Description
cause none String Type of damage that triggers an event.
damage_modifier 0.0 Decimal A modifier that adds to/removes the base damage from the damage cause. Does not reduce damage to less than 0.
damage_multiplier 1.0 Decimal A multiplier that modifies the base damage from the damage cause. If deals_damage is true the multiplier can only reduce the damage the entity will take to a minimum of 1.
deals_damage true Boolean If true the damage dealt to the entity will remove health, if set to false the entity will ignore the damage.
on_damage not set JSON Object Specifies filters for entity definitions and events.
on_damage_sound_event not set String Defines what sound to play, if any, when the on_damage filters are met.

on_damage

on_damage is a JSON object that is defined by two main parameters:

Name Default Value Type Description
filters not set Minecraft Filter Filters to use to define specific tests.
event not set String Defines what event to run.

cause

Important

A list of available damage sources can be found at Entity Damage Source located in the Addons Documentation.

Example

"minecraft:damage_sensor":{
    "triggers": {
        "on_damage": {
            "filters": {
                "test": "has_damage",
                "value": "fire"
            },
            "event": "minecraft:stop_drop_roll",
            "target": "self"
        }
    }
}

Vanilla entities examples

goat

"minecraft:damage_sensor": {
    "triggers": {
        "cause": "fall",
        "deals_damage": true,
        "damage_modifier": -20
    }
}

pillager

"minecraft:damage_sensor": {
          "triggers": {
            "on_damage": {
              "filters": {
                "all_of": [
                  {
                    "test": "has_damage",
                    "value": "fatal"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "player"
                  }
                ]
              },
              "event": "minecraft:gain_bad_omen",
              "target": "other"
            }
          }
        }

Vanilla entities using minecraft:damage_sensor