Hunger



Hunger is a new aspect of the game added in the Adventure Update, which governs several aspects of gameplay. Eating food, instead of directly restoring the player's Health, now fills up the Food Bar, which is constantly draining very, very slowly.

While the player is sprinting, the Food Bar will deplete much faster, and they will be unable to sprint at all once the bar falls to 30% or less.

The Food Bar does not drain when playing on Peaceful mode, but its effects on your character's health bar remain.

When you eat Rotten Flesh, there is a ~75% possibility that your Food Bar gets poisoned and depletes faster. There is also a chance of your food bar poisoning every time you eat Raw Chicken.

Effects

 * When the hunger bar is at 90% or higher, your health will slowly regenerate, at a rate of half a heart every 4 seconds.
 * When the hunger bar is below 30%, you will not be able to sprint
 * When the hunger bar is at 0%, your health will deplete at the same rate it would regenerate when at or above 90%. On Easy difficulty, the player's health stops dropping at 5 hearts, Normal stops at 1/2 a heart, and on Hard it keeps draining until you die..

Contrary to popular belief, having a full Food Bar does not keep your health bar from completely depleting when taking damage from external sources.

Food poisoning
Food poisoning is an effect induced by eating either raw chicken or rotten flesh, which turns the hunger bar green and slowly drains food. Rotten flesh has a high chance (~75%) to cause food poisoning, and raw chicken has a fairly low chance to cause it (~30%).

Behavior
Food poisoning lasts 30 seconds, and adds 15.0 to ExhaustionLevel over the duration. This is slightly less than. In peaceful mode, the hunger bar turns green, but does not get drained.

The duration of food poisoning doesn't stack, so if the player eats many poisonous foods at once, he or she will only feel the negative effects of a bit more than one of the poisonous foods.

Mechanics
There are four fields in level.dat which are related to hunger:
 * foodLevel ranges 0–20, this value represents your hunger bar.
 * foodSaturationLevel is an invisible additional hunger variable, which is depleted before main foodLevel value. Eating any food will also add some to this variable. Note that this value cannot exceed foodLevel.
 * foodTickTimer increases with every tick when foodLevel>17 or zero. When it reaches 80 it will reset and heal or deal one point of damage.
 * foodExhaustionLevel ranges from 0.0 to 4.0 and increases with every action you take. When the exhaustion level reaches above 4.0 it will get subtracted by 4.0 and subtracts 1 point from foodSaturationLevel or from foodLevel if foodSaturationLevel equals 0.