minecraft:behavior.defend_trusted_target for you with a switch.Get GodCraftOverview
minecraft:behavior.defend_trusted_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 attack whoever hurts an entity it trusts, like a fox protecting a player.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
attack_interval | integer | 0 | Seconds between attacks. |
entity_types | EntityTypes | none | Which entities can be chosen as targets. |
within_radius | number | 0 | How close, in blocks, the target must be. |
must_see | boolean | false | If true, the mob only picks targets it can see. |
must_see_forget_duration | number | 3 | Seconds the mob keeps looking for a hidden target before giving up. |
aggro_sound | LevelSoundEvent | "undefined" | Sound event played now and then while defending. |
on_defend_start | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | Event that fires when defending begins. |
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.defend_trusted_target": {
"attack_interval": 0,
"entity_types": {},
"within_radius": 0,
"must_see": false,
"must_see_forget_duration": 3,
"aggro_sound": "undefined",
"on_defend_start": {
"event": "",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"target": "self"
},
"priority": 0
}
}