Skip to main content

Food Component (Data Type)

An Object that describes a food component: how much it restores, how fast it is eaten and the effects it gives.

note

The saturation the player gets is worked out as food * saturation * 2.

Fields

FieldTypeDefaultDescription
hungerIntegerrequiredHow many hunger points the food restores. nutrition is accepted as an alias.
saturationFloatrequiredThe saturation value of the food, used in the formula above.
meatBooleanfalseWhether the food counts as meat.
always_edibleBooleanfalseWhether the food can be eaten at full hunger. can_always_eat is accepted as an alias.
snackBooleanfalseA shorthand for "eat_seconds": 0.8, as quick to eat as dried kelp. Ignored when eat_seconds is given.
eat_secondsFloat1.6How long the food takes to eat, in seconds. 1.6 is vanilla's normal speed, and 0.8 matches snack.
effectStatus Effect Instance plus chanceoptionalA status effect applied when the food is eaten, plus the chance of it applying.
effectsArray of the aboveoptionalSeveral status effects applied when the food is eaten, each with its own chance.

Every field of a Status Effect Instance is written directly inside effect, along with one extra field that only exists here:

FieldTypeDefaultDescription
chanceFloat1.0The probability that the effect applies, from 0.0 (never) to 1.0 (always).

Legacy spellings

Food components can be written three ways, and all of them parse, so older data packs don't need converting:

LegacyCurrentNotes
hungerhunger or nutritionBoth names read the same field.
always_ediblealways_edible or can_always_eatBoth names read the same field.
snack: truesnack: true or eat_seconds: 0.8snack still works, and eat_seconds wins if both are present.
"effect": { "effect": {…}, "probability": 1.0 }"effect": { …, "chance": 1.0 }The nested form, a Status Effect Instance under effect with probability beside it, is still accepted. In the current flat form the effect's own fields sit directly in effect, and the probability is called chance.
"effect": "minecraft:x" inside the instance"id": "minecraft:x"Both spellings of the effect ID work (see Status Effect Instance).

Examples

"food_component": {
    "hunger": 4,
    "saturation": 1.0
}

Food that restores 4 hunger and 8 saturation points.

"food_component": {
    "hunger": 2,
    "saturation": 0.3,
    "meat": true,
    "effect": {
        "effect": "minecraft:hunger",
        "duration": 600,
        "amplifier": 0,
        "chance": 0.3
    }
}

Food like raw chicken, which gives Hunger for 30 seconds 30% of the time.

"food_component": {
    "nutrition": 4,
    "saturation": 0.04,
    "can_always_eat": true,
    "eat_seconds": 0.8,
    "effect": {
        "effect": {
            "id": "minecraft:jump_boost",
            "duration": 200,
            "amplifier": 2
        },
        "probability": 1.0
    }
}

The same kind of component written with the vanilla-style field names and the nested effect form. Both this and the flat form above load.