1. Wiki
  2. /Entities
  3. /minecraft:behavior.random_search_and_dig

minecraft:behavior.random_search_and_dig

Don't want to write this by hand? GodCraft sets minecraft:behavior.random_search_and_dig for you with a switch.Get GodCraft

Overview

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

FieldTypeDefaultDescription
cooldown_rangeFloatRange{"max":0,"min":0}Random wait, in seconds, before the goal can run again.
speed_multipliernumber1Speeds the mob up or slows it down while this goal runs: 1 is normal speed.Range: 0 to …
find_valid_position_retriesinteger5How many tries the mob gets to find a good spot to dig.
target_dig_position_offsetnumber2.25How far in front of the mob's feet the dig spot is.
search_range_xzinteger10Width and length of the area searched for a dig spot.
search_range_yinteger7Height of the area searched for a dig spot.
goal_radiusnumber1.5How close the mob must get to the dig spot to count as arrived.
target_blocksBlock Descriptor[]noneBlocks the mob is allowed to dig in. Replaces the default list.
digging_duration_rangeFloatRange{"max":10,"min":8}How long, in seconds, the digging lasts.
item_tablestring""Path to the loot table that decides which item is dug up.
spawn_item_after_secondsnumber0Seconds of digging before the item appears.Range: 0 to …
spawn_item_pos_offsetnumber0How far in front of the mob the item appears.Range: 0 to …
on_searching_startActorDefinitionTrigger{"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_searchingActorDefinitionTrigger{"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_startActorDefinitionTrigger{"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_foundActorDefinitionTrigger{"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_diggingActorDefinitionTrigger{"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_successActorDefinitionTrigger{"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.
priorityinteger0Decides which goal wins when several want to run: lower numbers run first.Range: 0 to …
control_flagsGoal's control flags[]noneLists 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": []
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more