use of net.minecraft.world.food.FoodData in project MinecraftForge by MinecraftForge.
the class ForgeIngameGui method renderFood.
public void renderFood(int width, int height, PoseStack mStack) {
minecraft.getProfiler().push("food");
Player player = (Player) this.minecraft.getCameraEntity();
RenderSystem.enableBlend();
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
boolean unused = false;
FoodData stats = minecraft.player.getFoodData();
int level = stats.getFoodLevel();
for (int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left - i * 8 - 9;
int y = top;
int icon = 16;
byte background = 0;
if (minecraft.player.hasEffect(MobEffects.HUNGER)) {
icon += 36;
background = 13;
}
// Probably should be a += 1 but vanilla never uses this
if (unused)
background = 1;
if (player.getFoodData().getSaturationLevel() <= 0.0F && tickCount % (level * 3 + 1) == 0) {
y = top + (random.nextInt(3) - 1);
}
blit(mStack, x, y, 16 + background * 9, 27, 9, 9);
if (idx < level)
blit(mStack, x, y, icon + 36, 27, 9, 9);
else if (idx == level)
blit(mStack, x, y, icon + 45, 27, 9, 9);
}
RenderSystem.disableBlend();
minecraft.getProfiler().pop();
}