Skip to content

These docs were made completely by AI, so they might be right, or wrong, you'll need to test them yourself. This was made for a easier understanding of everything. So use at your own risk. If anything is wrong, please don't hurt to make a PR on the page you have a problem with. ON GITHUB

Food

Food items restore hunger and saturation when you eat them. The system is built around FoodItem and its subclasses: BowlFoodItem, SeedFoodItem, and GoldenAppleItem.

Files: Minecraft.World/FoodItem.h, Minecraft.World/FoodItem.cpp

FoodItem(int id, int nutrition, float saturationModifier, bool isMeat);

The constructor calls Item(id) (which does this->id = 256 + id) and then stores the food-specific fields. It also sets tabToDisplayOn to the food creative tab.

There is a second constructor that also takes an Item *craftingRemainingItem parameter, used for foods that leave something behind (like bowls).

FieldTypeDescription
nutritionintHunger points restored
saturationModifierfloatMultiplied by nutrition * 2 to get saturation restored
isMeatboolWhether wolves can eat it
canAlwaysEatboolIf true, edible even when hunger is full. Default false
effectIdintStatus effect applied after eating. 0 means no effect
effectDurationintDuration of the status effect in seconds
effectAmplifierintAmplifier for the status effect (0 = level I, 1 = level II, etc.)
effectProbabilityfloatChance (0.0 to 1.0) the effect is applied

The eating flow goes through several methods:

  1. use() checks canEat(). If the player can eat (hunger not full, or canAlwaysEat is set), calls player->startUsingItem() which begins the eating animation timer.

  2. Eating duration is the constant EAT_DURATION = (int)(20 * 1.6f) which is 32 ticks (about 1.6 seconds). The getUseDuration() method returns this value. The animation is UseAnim_eat.

  3. useTimeDepleted() runs when the timer finishes:

    • Decrements the item count by 1
    • Calls player->eat(nutrition, saturationModifier) which adds hunger and saturation to the player’s food data
    • Plays the random.burp sound at volume 0.5, pitch between 0.9 and 1.0
    • Calls addEatEffect() to apply any status effect
  4. addEatEffect() checks effectId != 0, rolls against effectProbability, and if it passes, applies a MobEffectInstance with the stored id, duration (converted to ticks by multiplying by 20), and amplifier.

FoodItem *setEatEffect(int effectId, int durationSec, int amplifier, float probability);
FoodItem *setCanAlwaysEat();

Both return this for chaining.

Files: Minecraft.World/FoodConstants.h, Minecraft.World/FoodConstants.cpp

This class holds all the constants that control the hunger system. There are no instances of this class. Everything is static.

ConstantValueDescription
MAX_FOOD20Maximum hunger bar value
MAX_SATURATION20.0Maximum saturation (equals MAX_FOOD cast to float)
START_SATURATION5.0Saturation when you spawn or respawn (MAX_SATURATION / 4)
SATURATION_FLOOR2.5Minimum saturation threshold (MAX_SATURATION / 8)
ConstantValueDescription
EXHAUSTION_DROP4.0When total exhaustion reaches this, saturation drops by 1 (or hunger drops by 1 if saturation is 0)
HEALTH_TICK_COUNT80Ticks between health changes from food (4 seconds)
HEAL_LEVEL18Hunger must be at or above 18 to regenerate health
STARVE_LEVEL0Hunger at or below 0 causes starvation damage

These constants are used when registering food items. The actual saturation restored is nutrition * saturationModifier * 2.

ConstantValueUsed By
FOOD_SATURATION_POOR0.1Cookies, rotten flesh
FOOD_SATURATION_LOW0.3Apples, raw meats, melon, poisonous potato, pumpkin pie
FOOD_SATURATION_NORMAL0.6Bread, cooked fish, cooked chicken, carrot, baked potato
FOOD_SATURATION_GOOD0.8Cooked pork, cooked beef, spider eye
FOOD_SATURATION_MAX1.0Not used by any food in the current code
FOOD_SATURATION_SUPERNATURAL1.2Golden apple, golden carrot

These control how fast your hunger bar drains. Every action adds to a running exhaustion total. When the total hits EXHAUSTION_DROP (4.0), it resets and one saturation (or hunger) point is consumed.

ActionExhaustionConstant
Jump0.2EXHAUSTION_JUMP
Sprint + Jump0.8EXHAUSTION_SPRINT_JUMP (= JUMP * 4)
Mine a block0.025EXHAUSTION_MINE
Attack0.3EXHAUSTION_ATTACK
Take damage0.1EXHAUSTION_DAMAGE
Walk (per meter)0.01EXHAUSTION_WALK
Sprint (per meter)0.1EXHAUSTION_SPRINT (= WALK * 10)
Swim (per meter)0.015EXHAUSTION_SWIM

Note that EXHAUSTION_SPRINT_JUMP and EXHAUSTION_SPRINT are computed from other constants, not hardcoded separately.

FoodIDNutritionSaturation ModSaturation RestoredIs MeatEat Effect
Apple26040.3 (Low)2.4No
Mushroom Stew28260.6 (Normal)7.2NoReturns bowl
Bread29750.6 (Normal)6.0No
Raw Porkchop31930.3 (Low)1.8Yes
Cooked Porkchop32080.8 (Good)12.8Yes
Golden Apple32241.2 (Supernatural)9.6NoSee below
Raw Fish34920.3 (Low)1.2No
Cooked Fish35050.6 (Normal)6.0No
Cookie35720.1 (Poor)0.4No
Melon Slice36020.3 (Low)1.2No
Raw Beef36330.3 (Low)1.8Yes
Cooked Beef (Steak)36480.8 (Good)12.8Yes
Raw Chicken36520.3 (Low)1.2Yes30% Hunger I 30s
Cooked Chicken36660.6 (Normal)7.2Yes
Rotten Flesh36740.1 (Poor)0.8Yes80% Hunger I 30s
Spider Eye37520.8 (Good)3.2No100% Poison I 5s
Carrot39140.6 (Normal)4.8NoPlantable (SeedFoodItem)
Potato39210.3 (Low)0.6NoPlantable (SeedFoodItem)
Baked Potato39360.6 (Normal)7.2No
Poisonous Potato39420.3 (Low)1.2No60% Poison I 5s
Golden Carrot39661.2 (Supernatural)14.4NoPotion ingredient only
Pumpkin Pie40080.3 (Low)4.8No

The “Saturation Restored” column is calculated as nutrition * saturationModifier * 2.

File: Minecraft.World/BowlFoodItem.h

Extends FoodItem. The constructor sets maxStackSize = 1 (bowls of stew do not stack).

When you finish eating, useTimeDepleted() gives you back an empty bowl (Item::bowl, ID 281). Used for mushroom stew (ID 282).

Files: Minecraft.World/GoldenAppleItem.h, Minecraft.World/GoldenAppleItem.cpp

The constructor calls setStackedByData(true) so regular and enchanted golden apples stack separately based on aux value.

VariantAux ValueRarityFoil (Glint)
Regular0rare (aqua color)No
Enchanted>0epic (magenta color)Yes

addEatEffect() is overridden with special behavior:

  • Enchanted (aux > 0): Regeneration IV for 30 seconds (amplifier 3), Damage Resistance for 300 seconds (amplifier 0), Fire Resistance for 300 seconds (amplifier 0).
  • Regular (aux == 0): Falls through to the base FoodItem::addEatEffect(), which applies Regeneration I for 5 seconds (set during registration with setEatEffect).

Both variants have canAlwaysEat set to true, so you can eat them even when your hunger bar is full.

isFoil() returns true when auxValue > 0, which makes the enchanted golden apple render with the shimmery enchantment glint effect.

Files: Minecraft.World/SeedFoodItem.h, Minecraft.World/SeedFoodItem.cpp

Extends FoodItem and can be both eaten and planted on farmland.

SeedFoodItem(int id, int nutrition, float satMod, int resultId, int targetLand);
ParameterDescription
resultIdThe tile ID that gets placed when you plant (e.g., carrot crop tile)
targetLandThe tile ID this can be planted on (farmland)

useOn() checks:

  1. The face must be the top face (UP).
  2. The player must be able to use the block.
  3. The player must be able to use the block above.
  4. The block at the position must be targetLand (farmland).
  5. The block above must be air.

If all pass, it places the resultId tile above the farmland and decrements the item count. If the player is not looking at a valid planting spot, the food just gets eaten through the normal FoodItem::use() path.

ItemIDNutritionPlants
Carrot3914Carrot crop tile
Potato3921Potato crop tile

The food system is the same between LCEMP and MinecraftConsoles. Same FoodItem class, same nutrition values, same saturation modifiers, same exhaustion constants. No new food items are added in the MinecraftConsoles version.

The golden apple mechanics, bowl food, and seed food subclasses are all identical.