1. Wiki
  2. /Entities
  3. /minecraft:behavior.defend_village_target

minecraft:behavior.defend_village_target

Don't want to write this by hand? GodCraft sets minecraft:behavior.defend_village_target for you with a switch.Get GodCraft

Overview

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

FieldTypeDefaultDescription
attack_chancenumber0.05Chance to attack a village enemy. 1.0 means 100%.Range: 0 to 1
attack_ownerbooleanfalseIf true, the mob may attack its own owner.
must_reachbooleanfalseIf true, the mob needs a walkable path to the target.
must_seebooleanfalseIf true, the target must be both in range and in sight.
within_radiusnumber0How far the target can get before it is dropped, when no follow range is set.Range: 0 to …
must_see_forget_durationnumber3Seconds the target can stay out of sight before it is dropped. Only used with must_see.Range: 0 to …
persist_timenumber0Seconds the mob keeps attacking after the target stops being valid.Range: 0 to …
entity_typesEntityTypesnoneWhich entities can be chosen as targets.
priorityinteger0Lower numbers run first: when two goals compete, the one with the smaller priority wins.Range: 0 to …
control_flagsGoal's control flags[]noneWhich 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": {}
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more