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

minecraft:behavior.defend_trusted_target

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

Overview

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

FieldTypeDefaultDescription
attack_intervalinteger0Seconds between attacks.
entity_typesEntityTypesnoneWhich entities can be chosen as targets.
within_radiusnumber0How close, in blocks, the target must be.
must_seebooleanfalseIf true, the mob only picks targets it can see.
must_see_forget_durationnumber3Seconds the mob keeps looking for a hidden target before giving up.
aggro_soundLevelSoundEvent"undefined"Sound event played now and then while defending.
on_defend_startActorDefinitionTrigger{"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.
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_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
  }
}

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