Class in @minecraft/server
Extends ItemComponent
What eating a food gives. Read only.
import { ItemFoodComponent } from '@minecraft/server';Example
Section titled “Example”import { ItemStack, type ItemFoodComponent } from '@minecraft/server';
const item = new ItemStack('minecraft:diamond_sword');const component: ItemFoodComponent | undefined = item.getComponent('minecraft:food');if (component) { console.log(item.typeId, component.canAlwaysEat);}import { ItemStack } from '@minecraft/server';
const item = new ItemStack('minecraft:diamond_sword');const component = item.getComponent('minecraft:food');if (component) { console.log(item.typeId, component.canAlwaysEat);}Properties
Section titled “Properties”componentId
Section titled “componentId”static read-only
static readonly componentId = "minecraft:food";canAlwaysEat
Section titled “canAlwaysEat”read-only
readonly canAlwaysEat: boolean;Whether it can be eaten with a full hunger bar.
nutrition
Section titled “nutrition”read-only
readonly nutrition: number;The hunger points it fills.
saturationModifier
Section titled “saturationModifier”read-only
readonly saturationModifier: number;Saturation given is the nutrition times this times two.
usingConvertsTo
Section titled “usingConvertsTo”read-only
readonly usingConvertsTo: string;What’s left in the hand after, as minecraft:bowl, or "" for nothing.
Used by
Section titled “Used by”ItemComponentTypeMap.food, ItemComponentTypeMap.minecraft:food
Inherited
Section titled “Inherited”From ItemComponent: typeId, isValid