minecraft:behavior.avoid_block for you with a switch.Get GodCraftOverview
minecraft:behavior.avoid_block 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 move away from certain blocks, like hoglins avoiding warped fungus.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
walk_speed_modifier | number | 1 | Speed multiplier while walking away. 1.0 keeps normal speed. |
sprint_speed_modifier | number | 1 | Speed multiplier while sprinting away. 1.0 keeps normal speed. |
search_range | integer | 0 | How far sideways, in blocks, the mob looks for blocks to avoid. |
search_height | integer | 0 | How far up and down, in blocks, the mob looks for blocks to avoid. |
tick_interval | integer | 1 | How often, in ticks, the goal checks whether it should start. |
target_selection_method | string | "nearest" | How the block to avoid is picked, for example the nearest one. |
on_escape | ActorDefinitionTrigger[] | none | Events that fire when the mob has escaped the block. |
target_blocks | Item Descriptor[] | none | The blocks this mob stays away from. |
avoid_block_sound | LevelSoundEvent | "undefined" | Sound event played while avoiding a block. |
sound_interval | FloatRange | {"max":8,"min":3} | Random wait range in seconds between avoid 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_block": {
"walk_speed_modifier": 1,
"sprint_speed_modifier": 1,
"search_range": 0,
"search_height": 0,
"tick_interval": 1,
"target_selection_method": "nearest",
"on_escape": [],
"target_blocks": []
}
}