Skip to content

Commit

Permalink
Only render the menu once per render pass (#159)
Browse files Browse the repository at this point in the history
RenderGuiOverlayEvent.Post fires once per HUD component (health, armor,
hotbar, scoreboard, boss bar, player list, ...). This means that the
menu was rendered more than 25 times when once would be sufficient.

Arbitrarily choose the player list component as an anchor.

This becomes an issue when this mod is combined in combination with my
mod Auto HUD, as this mod moves some of these components in different
directions. That leads to the menu being duplicated on screen, offset
off each other.
  • Loading branch information
Crendgrim committed Oct 26, 2023
1 parent 98a2f83 commit 0dd57c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/dmillerw/menu/handler/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand Down Expand Up @@ -49,6 +50,10 @@ public static void onRenderOverlay(RenderGuiOverlayEvent event) {
return;
}

if (!(event.getOverlay().id().equals(VanillaGuiOverlay.PLAYER_LIST.id()))) {
return;
}

Minecraft mc = Minecraft.getInstance();
if (mc.level != null && !mc.options.hideGui && !mc.isPaused() && RadialMenuScreen.active) {
GuiGraphics guiGraphics = event.getGuiGraphics();
Expand Down

0 comments on commit 0dd57c5

Please sign in to comment.