minecraft:behavior.defend_village_target for you with a switch.Get GodCraftOverview
minecraft:behavior.defend_village_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 enemies of its village, like iron golems. Players the village dislikes are attacked even if filters say otherwise.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
attack_chance | number | 0.05 | Chance to attack a village enemy. 1.0 means 100%.Range: 0 to 1 |
attack_owner | boolean | false | If true, the mob may attack its own owner. |
must_reach | boolean | false | If true, the mob needs a walkable path to the target. |
must_see | boolean | false | If true, the target must be both in range and in sight. |
within_radius | number | 0 | How far the target can get before it is dropped, when no follow range is set.Range: 0 to … |
must_see_forget_duration | number | 3 | Seconds the target can stay out of sight before it is dropped. Only used with must_see.Range: 0 to … |
persist_time | number | 0 | Seconds the mob keeps attacking after the target stops being valid.Range: 0 to … |
entity_types | EntityTypes | none | Which entities can be chosen as targets. |
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_village_target": {
"attack_chance": 0.05,
"attack_owner": false,
"must_reach": false,
"must_see": false,
"within_radius": 0,
"must_see_forget_duration": 3,
"persist_time": 0,
"entity_types": {}
}
}