minecraft:behavior.hurt_by_target for you with a switch.Get GodCraftOverview
minecraft:behavior.hurt_by_target is an entity component: it goes in the components object of a custom mob, or in one of its component groups. AI goal that makes the mob fight back against whatever hurt it.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
entity_types | EntityTypes | none | Which attackers the mob will fight back against. |
hurt_owner | boolean | false | If true, the mob can also attack its owner and other mobs with the same owner. |
priority | integer | 0 | Lower numbers run first: when two goals compete, the one with the smaller priority wins.Range: 0 to … |
control_flags | Goal's control flags[] | none | Which body parts this goal takes over (move, look, jump), so goals using the same parts cannot run together. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:behavior.hurt_by_target": {
"entity_types": {},
"hurt_owner": false,
"priority": 0,
"control_flags": []
}
}