minecraft:behavior.random_search_and_dig for you with a switch.Get GodCraftOverview
minecraft:behavior.random_search_and_dig is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Makes the mob pick a reachable block, walk to it and dig up an item from a loot table, like a sniffer finding seeds. By default it digs in dirt, grass, podzol, moss and mud style blocks.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
cooldown_range | FloatRange | {"max":0,"min":0} | Random wait, in seconds, before the goal can run again. |
speed_multiplier | number | 1 | Speeds the mob up or slows it down while this goal runs: 1 is normal speed.Range: 0 to … |
find_valid_position_retries | integer | 5 | How many tries the mob gets to find a good spot to dig. |
target_dig_position_offset | number | 2.25 | How far in front of the mob's feet the dig spot is. |
search_range_xz | integer | 10 | Width and length of the area searched for a dig spot. |
search_range_y | integer | 7 | Height of the area searched for a dig spot. |
goal_radius | number | 1.5 | How close the mob must get to the dig spot to count as arrived. |
target_blocks | Block Descriptor[] | none | Blocks the mob is allowed to dig in. Replaces the default list. |
digging_duration_range | FloatRange | {"max":10,"min":8} | How long, in seconds, the digging lasts. |
item_table | string | "" | Path to the loot table that decides which item is dug up. |
spawn_item_after_seconds | number | 0 | Seconds of digging before the item appears.Range: 0 to … |
spawn_item_pos_offset | number | 0 | How far in front of the mob the item appears.Range: 0 to … |
on_searching_start | 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 runs when the mob starts searching. |
on_fail_during_searching | 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 runs if searching fails. |
on_digging_start | 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 runs when the mob stops searching and starts digging. |
on_item_found | 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 runs when an item is dug up. |
on_fail_during_digging | 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 runs if digging fails. |
on_success | 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 runs when searching and digging are both done. |
priority | integer | 0 | Decides which goal wins when several want to run: lower numbers run first.Range: 0 to … |
control_flags | Goal's control flags[] | none | Lists the body parts this goal takes control of (such as move, look or jump), so goals that need the same part don't run together. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:behavior.random_search_and_dig": {
"cooldown_range": {
"max": 0,
"min": 0
},
"speed_multiplier": 1,
"find_valid_position_retries": 5,
"target_dig_position_offset": 2.25,
"search_range_xz": 10,
"search_range_y": 7,
"goal_radius": 1.5,
"target_blocks": []
}
}