minecraft:behavior.avoid_block
Allows this entity to avoid certain blocks.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
walk_speed_modifier | Decimal | 1 | Modifier for walking speed. 1.0 means keep the regular speed, while higher numbers make the walking speed faster. |
sprint_speed_modifier | Decimal | 1 | Modifier for sprint speed. 1.0 means keep the regular speed, while higher numbers make the sprint speed faster. |
search_range | Integer | 0 | Maximum distance to look for a block in xz. |
search_height | Integer | 0 | Maximum distance to look for a block in y. |
tick_interval | Integer | 1 | Should start tick interval. |
target_selection_method | Text | "nearest" | Block search method. |
on_escape | List of object | [] | Escape triggers. |
event | Text | "" | |
target | Textself, other, player, target, parent, baby, block, damager, holder, item | "self" | |
filters | Object 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. |
test | Text | — | The name of the test to apply. |
subject | Boolean or Integer or Decimal or Text | — | The subject of this filter test. |
operator | Boolean or Integer or Decimal or Text | — | The comparison to apply with 'value'. |
domain | Boolean or Integer or Decimal or Text | — | The domain the test should be performed in. |
value | Boolean or Integer or Decimal or Text | — | The value being compared with the test. |
target_blocks | List of text or object | [] | List of block types this mob avoids. |
avoid_block_sound | Textitem.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 a block. |
sound_interval | Object | {"max": 8, "min": 3} | The range of time in seconds to randomly wait before playing the sound again. |
min | Decimal | 0 | |
max | Decimal | 0 | |
priority | Integermin 0 | 0 | |
control_flags | List of text | [] |
Example from the game files
This is how vanilla Hoglin uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:behavior.avoid_block": {
"priority": 1,
"tick_interval": 5,
"search_range": 8,
"search_height": 4,
"walk_speed_modifier": 1,
"sprint_speed_modifier": 1,
"avoid_block_sound": "retreat",
"sound_interval": {
"min": 2.0,
"max": 5.0
},
"target_selection_method": "nearest",
"target_blocks": [
"minecraft:warped_fungus",
"minecraft:portal",
"minecraft:respawn_anchor"
],
"on_escape": [
{
"event": "escaped_event",
"target": "self"
}
]
}
}Used by 2
Vanilla entities with minecraft:behavior.avoid_block in their definition: