minecraft:behavior.defend_village_target
Allows the entity to stay in a village and defend the village from aggressors. If a player is in bad standing with the village this goal will cause the entity to attack the player regardless of filter conditions.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
attack_chance | Decimal0 to 1 | 0.05 | The percentage chance that the entity has to attack aggressors of its village, where 1.0 = 100%. |
attack_owner | Boolean | false | If true, this entity can attack its owner. |
must_reach | Boolean | false | If true, this entity requires a path to the target. |
must_see | Boolean | false | Determines if target-validity requires this entity to be in range only, or both in range and in sight. |
within_radius | Decimalmin 0 | 0 | Maximum distance this entity can be from the target when following it, otherwise the target becomes invalid. This value is only used if the entity doesn't declare "minecraft:follow_range". |
must_see_forget_duration | Decimalmin 0 | 3 | Time (in seconds) the target must not be seen by this entity to become invalid. Used only if "must_see" is true. |
persist_time | Decimalmin 0 | 0 | Time (in seconds) this entity can continue attacking the target after the target is no longer valid. |
entity_types | List of object or Object | [] | Filters which types of targets are valid for this entity. |
filters | Object or List of object | {"AND": null, "NOT": null, "OR": null, "all": null, "all_… | Conditions that make this entry in the list valid |
max_dist | Decimal | 16 | Maximum distance this mob can be away to be a valid choice |
max_height | Decimal | -1 | Maximum height this mob can be away to be a valid choice |
max_flee | Decimal | 10 | Maximum distance this mob can be from the target to stop fleeing |
walk_speed_multiplier | Decimal | 1 | Multiplier for the walking speed. A value of 1.0 means the speed is unchanged |
sprint_speed_multiplier | Decimal | 1 | Multiplier for the sprinting speed. A value of 1.0 means the speed is unchanged |
priority | Integer | 0 | Priority for this mob type |
check_if_outnumbered | Boolean | false | If true, the mob will check if its outnumbered |
reevaluate_description | Boolean | false | If true, the mob will stop being targeted if it stops meeting any conditions. |
cooldown | Integer | 0 | The amount of time in seconds that the mob has to wait before selecting a target of the same type again |
must_see | Boolean | — | If true, the mob has to be visible to be a valid choice |
must_see_forget_duration | Integer | 3 | Determines the amount of time in seconds that this mob will look for a target before forgetting about it and looking for a new one when the target isn't visible any more |
priority | Integermin 0 | 0 | |
control_flags | List of text | [] |
Example from the game files
This is how vanilla Iron Golem uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:behavior.defend_village_target": {
"must_reach": true,
"entity_types": [
{
"filters": {
"AND": [
{
"OR": [
{
"test": "is_family",
"subject": 1,
"operator": 0,
"value": "mob"
},
{
"test": "is_family",
"subject": 1,
"operator": 0,
"value": "player"
}
]
}
]
}
}
],
"priority": 1
}
}Used by 1
Vanilla entities with minecraft:behavior.defend_village_target in their definition:
Related components
behavior.hurt_by_targetbehavior.follow_target_captainbehavior.defend_trusted_targetbehavior.jump_around_targetbehavior.look_at_targetbehavior.move_around_targetbehavior.move_towards_targetbehavior.owner_hurt_by_targetbehavior.owner_hurt_targetbehavior.stalk_and_pounce_on_targetbehavior.target_when_pushedbehavior.wither_target_highest_damagebehavior.follow_target_leaderbehavior.vex_copy_owner_target