Does saturation increase before or after hunger?

Saturation is a hidden value that is like a second hunger bar.

Most foods that you'll be eating constanly (meat, bread etc, but not watermelon) give you more saturation than hunger, but saturation can never be higher than your current food level.

This means that if I have 10 food, and 0 saturation, and I eat something that gives me 0 food and 20 saturation (doesn't actually exist) I'll only end up with 10 food and 10 saturation.

When I eat a food that gives me both, will I gain the food first, and then saturation, or the saturation first and then the food? That is, if I have 10 hunger and 0 saturation and eat something worth 10 and 20, will I end up with 20/10 or 20/20?

If I gain the saturation first, it makes it more important to constantly top off my hunger, if I want to use it most effectively, instead of waiting until I'm really low and then refilling with a couple of pieces of food.


Solution 1:

The food level increases first. That's all there is to it. Here's a piece of code from FoodStats.java, courtesy of the Minecraft Coder Pack:

public void addFoodStats(int foodIncrease, float saturationIncrease)
{
    foodLevel = Math.min(foodIncrease + foodLevel, 20);
    foodSaturationLevel = Math.min(foodSaturationLevel + (float)foodIncrease * saturationIncrease * 2.0F, foodLevel);
}

As you can see, the food level is increased first. Then, the saturation level is added based on the new food level value.

Therefore, waiting vs constant top-offs will probably have little effect on your food's efficiency.