minecraft:behavior.eat_block
Allows the entity to consume a block, replace the eaten block with another block, and trigger an event as a result.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
time_until_eat | Decimal | 1.8 | The amount of time (in seconds) it takes for the block to be eaten upon a successful eat attempt. |
on_eat | Object | {"event": "", "filters": {"AND": null, "NOT": null, "OR":… | The event to trigger when the block eating animation has completed. |
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. |
success_chance | Text or Object or Decimal | 0.02 | A molang expression defining the success chance the entity has to consume a block. |
eat_and_replace_block_pairs | List of object | [{"eat_block": "grass", "replace_block": "dirt"}, {"eat_b… | A collection of pairs of blocks; the first ("eat_block") is the block the entity should eat, the second ("replace_block") is the block that should replace the eaten block. |
eat_block | Text | "" | The block the entity should eat. |
replace_block | Text | "" | The block that should replace the eaten block. |
priority | Integermin 0 | 0 | |
control_flags | List of text | [] |
Example from the game files
This is how vanilla Sheep uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:behavior.eat_block": {
"priority": 6,
"success_chance": "query.is_baby ? 0.02 : 0.001",
"time_until_eat": 1.8,
"eat_and_replace_block_pairs": [
{
"eat_block": "grass",
"replace_block": "dirt"
},
{
"eat_block": "tallgrass",
"replace_block": "air"
},
{
"eat_block": "short_dry_grass",
"replace_block": "air"
},
{
"eat_block": "tall_dry_grass",
"replace_block": "air"
}
],
"on_eat": {
"event": "minecraft:on_eat_block",
"target": "self"
}
}
}Used by 1
Vanilla entities with minecraft:behavior.eat_block in their definition:
Related components
behavior.pickup_itemsbehavior.move_to_villagebehavior.harvest_farm_blockbehavior.lay_eggbehavior.move_indoorsbehavior.move_outdoorsbehavior.place_blockbehavior.raid_gardenbehavior.digbehavior.dragonscanningbehavior.drop_item_forbehavior.eat_carried_itembehavior.eat_mobbehavior.fertilize_farm_blockbehavior.hold_groundbehavior.inspect_bookshelfbehavior.move_through_villagebehavior.open_doorbehavior.random_search_and_digbehavior.restrict_open_doorbehavior.snackingbehavior.stroll_towards_villagebehavior.take_blockbehavior.transport_items