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

minecraft:behavior.eat_block

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

Overview

minecraft:behavior.eat_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 eat a block and turn it into another one, then run an event, like a sheep eating grass to regrow wool.

Fields

FieldTypeDefaultDescription
time_until_eatnumber1.8Seconds the eating takes once it starts.
on_eatActorDefinitionTrigger{"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 finishes eating.
success_chanceMolang expression0.02Molang expression giving the chance to eat. Use a small value so it happens rarely.
eat_and_replace_block_pairsEatAndReplaceBlockPair[][{"eat_block":"grass","replace_block":"dirt"},{"eat_block":"short_grass","replace_block":"air"},{"eat_block":"fern","replace_block":"air"}]Pairs of blocks: the block that gets eaten and the block left in its place.
priorityinteger0Lower numbers run first: when two goals compete, the one with the smaller priority wins.Range: 0 to …
control_flagsGoal's control flags[]noneWhich 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.eat_block": {
    "time_until_eat": 1.8,
    "on_eat": {
      "event": "",
      "filters": {
        "AND": null,
        "NOT": null,
        "OR": null,
        "all": null,
        "all_of": null,
        "any": null,
        "any_of": null,
        "none_of": null
      },
      "target": "self"
    },
    "success_chance": 0.02,
    "eat_and_replace_block_pairs": [
      {
        "eat_block": "grass",
        "replace_block": "dirt"
      },
      {
        "eat_block": "short_grass",
        "replace_block": "air"
      },
      {
        "eat_block": "fern",
        "replace_block": "air"
      }
    ],
    "priority": 0,
    "control_flags": []
  }
}

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