minecraft:behavior.avoid_mob_type

Allows the entity to run away from other entities that meet the criteria specified.

Properties

PropertyTypeDefaultWhat it does
ignore_visibilityBooleanfalseWhether or not to ignore direct line of sight while this entity is running away from other specified entities.
avoid_target_xzInteger16The next target position the entity chooses to avoid another entity will be chosen within this XZ Distance.
avoid_target_yInteger7The next target position the entity chooses to avoid another entity will be chosen within this Y Distance.
max_distDecimal3Maximum distance to look for an avoid target for the entity.
max_fleeDecimal10How many blocks away from its avoid target the entity must be for it to stop fleeing from the avoid target.
probability_per_strengthDecimalmax 11Percent chance this entity will stop avoiding another entity based on that entity's strength, where 1.0 = 100%.
river_speed_multiplierDecimal0.75Multiplier for speed when following river. 1.0 means keep the regular speed, while higher numbers make the speed faster.
walk_speed_multiplierDecimal1Multiplier for walking speed. 1.0 means keep the regular speed, while higher numbers make the walking speed faster.
sprint_speed_multiplierDecimal1Multiplier for sprint speed. 1.0 means keep the regular speed, while higher numbers make the sprint speed faster.
sprint_distanceDecimal7How many blocks within range of its avoid target the entity must be for it to begin sprinting away from the avoid target.
entity_typesList of object or Object[]The list of conditions another entity must meet to be a valid target to avoid.
filtersObject or List of object{"AND": null, "NOT": null, "OR": null, "all": null, "all_…Conditions that make this entry in the list valid
max_distDecimal16Maximum distance this mob can be away to be a valid choice
max_heightDecimal-1Maximum height this mob can be away to be a valid choice
max_fleeDecimal10Maximum distance this mob can be from the target to stop fleeing
walk_speed_multiplierDecimal1Multiplier for the walking speed. A value of 1.0 means the speed is unchanged
sprint_speed_multiplierDecimal1Multiplier for the sprinting speed. A value of 1.0 means the speed is unchanged
priorityInteger0Priority for this mob type
check_if_outnumberedBooleanfalseIf true, the mob will check if its outnumbered
reevaluate_descriptionBooleanfalseIf true, the mob will stop being targeted if it stops meeting any conditions.
cooldownInteger0The amount of time in seconds that the mob has to wait before selecting a target of the same type again
must_seeBoolean—If true, the mob has to be visible to be a valid choice
must_see_forget_durationInteger3Determines 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
remove_targetBooleanfalseDetermine if we should remove target when fleeing or not.
on_escape_eventObject{"event": "", "filters": {"AND": null, "NOT": null, "OR":…Event that is triggered when escaping from a mob.
eventText""
targetTextself, other, player, target, parent, baby, block, damager, holder, item"self"
filtersObject or List of object{"AND": null, "NOT": null, "OR": null, "all": null, "all_…Filters allow data objects to specify test criteria which allows their use. Filters can be defined by a single object of type (Filter Test), an array of tests, collection groups, or a combination of these objects.
testText—The name of the test to apply.
subjectBoolean or Integer or Decimal or Text—The subject of this filter test.
operatorBoolean or Integer or Decimal or Text—The comparison to apply with 'value'.
domainBoolean or Integer or Decimal or Text—The domain the test should be performed in.
valueBoolean or Integer or Decimal or Text—The value being compared with the test.
avoid_mob_soundTextitem.use.on, hit, step, step.baby, fly, jump, jump.prevent, break, place, heavy.step, gallop, fall, hurt, hurt.baby, hurt.in.water, death, death.baby, death.in.water, death.to.zombie, ambient, ambient.baby, ambient.in.water, ambient.in.air, ambient.tame …"undefined"The sound event to play when the mob is avoiding another mob.
sound_intervalObject{"max": 8, "min": 3}The range of time in seconds to randomly wait before playing the sound again.
minDecimal0
maxDecimal0
priorityIntegermin 00
control_flagsList of text[]

Example from the game files

This is how vanilla Piglin uses it in Minecraft Bedrock 1.26.60.5:

{
  "minecraft:behavior.avoid_mob_type": {
    "priority": 4,
    "remove_target": true,
    "entity_types": [
      {
        "filters": {
          "any_of": [
            {
              "test": "is_family",
              "subject": "other",
              "value": "zombie_pigman"
            }
          ]
        },
        "max_dist": 6
      },
      {
        "filters": {
          "any_of": [
            {
              "test": "is_family",
              "subject": "other",
              "value": "zoglin"
            }
          ]
        },
        "max_dist": 6
      },
      {
        "filters": {
          "all_of": [
            {
              "test": "has_target",
              "subject": "other"
            },
            {
              "test": "is_family",
              "subject": "other",
              "value": "hoglin"
            }
          ]
        },
        "sprint_speed_multiplier": 1.2,
        "check_if_outnumbered": true
      }
    ],
    "on_escape_event": {
      "event": "become_calm_event",
      "target": "self"
    },
    "avoid_mob_sound": "retreat",
    "sound_interval": {
      "min": 2.0,
      "max": 5.0
    }
  }
}

Used by 28

Vanilla entities with minecraft:behavior.avoid_mob_type in their definition:

Related components