minecraft:on_hurt_by_player for you with a switch.Get GodCraftOverview
minecraft:on_hurt_by_player is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Runs an event when a player attacks this entity. Handy for mobs that turn hostile only after a player hits them.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
event | string | "" | Name of the event to run. |
target | FilterSubject | "self" | Who the event runs on, for example self or other. |
filters | Filter Group | {"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null} | Conditions that must be true for the event to run. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:on_hurt_by_player": {
"event": "",
"target": "self",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
}
}
}