AppleSkin

AppleSkin

196M Downloads

Exhaustion still renders when food hud is cancelled with Forge event

BrownBear85 opened this issue ยท 1 comments

commented

I'm canceling RenderGuiOverlayEvent on Forge 1.20.1 when event.getOverlay() == VanillaGuiOverlay.FOOD_LEVEL.type() and this successfully cancels the food icons and saturation overlay, however the saturation checkerboard pattern that renders behind the food icons.

image

commented

You'll want to cancel both RenderGuiOverlayEvent.Pre and RenderGuiOverlayEvent.Post.

@SubscribeEvent
public void onRenderGuiOverlayPre(RenderGuiOverlayEvent.Pre event)
{
if (event.getOverlay() == GuiOverlayManager.findOverlay(FOOD_LEVEL_ELEMENT))
{
Minecraft mc = Minecraft.getInstance();
ForgeGui gui = (ForgeGui) mc.gui;
boolean isMounted = mc.player.getVehicle() instanceof LivingEntity;
if (!isMounted && !mc.options.hideGui && gui.shouldDrawSurvivalElements())
{
renderExhaustion(gui, event.getGuiGraphics(), event.getPartialTick(), event.getWindow().getScreenWidth(), event.getWindow().getScreenHeight());
}
}
}
@SubscribeEvent
public void onRenderGuiOverlayPost(RenderGuiOverlayEvent.Post event)
{
if (event.getOverlay() == GuiOverlayManager.findOverlay(FOOD_LEVEL_ELEMENT))
{
Minecraft mc = Minecraft.getInstance();
ForgeGui gui = (ForgeGui) mc.gui;
boolean isMounted = mc.player.getVehicle() instanceof LivingEntity;
if (!isMounted && !mc.options.hideGui && gui.shouldDrawSurvivalElements())
{
renderFoodOrHealthOverlay(gui, event.getGuiGraphics(), event.getPartialTick(), event.getWindow().getScreenWidth(), event.getWindow().getScreenHeight(), RenderOverlayType.FOOD);
}
}
else if (event.getOverlay() == GuiOverlayManager.findOverlay(PLAYER_HEALTH_ELEMENT))
{
Minecraft mc = Minecraft.getInstance();
ForgeGui gui = (ForgeGui) mc.gui;
if (!mc.options.hideGui && gui.shouldDrawSurvivalElements())
{
renderFoodOrHealthOverlay(gui, event.getGuiGraphics(), event.getPartialTick(), event.getWindow().getScreenWidth(), event.getWindow().getScreenHeight(), RenderOverlayType.HEALTH);
}
}
}