minecraft:behavior.avoid_mob_type for you with a switch.Get GodCraftOverview
minecraft:behavior.avoid_mob_type 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 run from certain other entities, like creepers fleeing cats.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
ignore_visibility | boolean | false | If true, the mob flees even when it cannot see the threat. |
avoid_target_xz | integer | 16 | How far sideways the mob may pick its next escape spot. |
avoid_target_y | integer | 7 | How far up or down the mob may pick its next escape spot. |
max_dist | number | 3 | How far away the mob notices something to avoid. |
max_flee | number | 10 | Once this many blocks from the threat, the mob stops running. |
probability_per_strength | number | 1 | Chance, based on the threat's strength, that the mob gives up fleeing. 1.0 means 100%.Range: … to 1 |
river_speed_multiplier | number | 0.75 | Speed multiplier when the escape follows a river. 1.0 keeps normal speed. |
walk_speed_multiplier | number | 1 | Speed multiplier while walking away. 1.0 keeps normal speed. |
sprint_speed_multiplier | number | 1 | Speed multiplier while sprinting away. 1.0 keeps normal speed. |
sprint_distance | number | 7 | When the threat is closer than this many blocks, the mob starts to sprint. |
entity_types | EntityTypes | none | Which entities to run from, written as filters. |
remove_target | boolean | false | If true, the mob forgets its current target while fleeing. |
on_escape_event | ActorDefinitionTrigger | {"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 the mob gets away. |
avoid_mob_sound | LevelSoundEvent | "undefined" | Sound event played while running away. |
sound_interval | FloatRange | {"max":8,"min":3} | Random wait range in seconds between flee sounds. |
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.avoid_mob_type": {
"ignore_visibility": false,
"avoid_target_xz": 16,
"avoid_target_y": 7,
"max_dist": 3,
"max_flee": 10,
"probability_per_strength": 1,
"river_speed_multiplier": 0.75,
"walk_speed_multiplier": 1
}
}