From 27b0084605a89230db03bfe151012c3ac95e4492 Mon Sep 17 00:00:00 2001 From: Sara Freimer Date: Fri, 14 Jul 2023 14:19:12 -0500 Subject: [PATCH] Make our status overlay rendering respect left and right height of gui overlays --- .../java/mekanism/client/ClientRegistration.java | 3 ++- .../client/render/hud/MekanismStatusOverlay.java | 13 ++++++++++++- src/main/resources/META-INF/accesstransformer.cfg | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/client/ClientRegistration.java b/src/main/java/mekanism/client/ClientRegistration.java index 624907c3ff3..6bf0cef83d3 100644 --- a/src/main/java/mekanism/client/ClientRegistration.java +++ b/src/main/java/mekanism/client/ClientRegistration.java @@ -298,7 +298,8 @@ public static void registerOverlays(RegisterGuiOverlaysEvent event) { //Note: We don't need to include our modid in the id as the active context is grabbed for making an RL inside the event event.registerBelowAll("radiation_overlay", RadiationOverlay.INSTANCE); event.registerAbove(VanillaGuiOverlay.ARMOR_LEVEL.id(), "energy_level", MekaSuitEnergyLevel.INSTANCE); - event.registerAbove(VanillaGuiOverlay.RECORD_OVERLAY.id(), "status_overlay", MekanismStatusOverlay.INSTANCE); + //Render status overlay after item name rather than action bar (record_overlay) so that things like the sleep fade will render in front of our overlay + event.registerAbove(VanillaGuiOverlay.ITEM_NAME.id(), "status_overlay", MekanismStatusOverlay.INSTANCE); event.registerAbove(VanillaGuiOverlay.HOTBAR.id(), "hud", MekanismHUD.INSTANCE); } diff --git a/src/main/java/mekanism/client/render/hud/MekanismStatusOverlay.java b/src/main/java/mekanism/client/render/hud/MekanismStatusOverlay.java index 7bab158853b..a54acb7510e 100644 --- a/src/main/java/mekanism/client/render/hud/MekanismStatusOverlay.java +++ b/src/main/java/mekanism/client/render/hud/MekanismStatusOverlay.java @@ -38,9 +38,20 @@ public void render(ForgeGui gui, GuiGraphics guiGraphics, float partialTicks, in Color color = Color.rgbad(1, 1, 1, modeSwitchTimer / 100F); Font font = gui.getFont(); int componentWidth = font.width(scrollTextComponent); + int targetShift = Math.max(59, Math.max(gui.leftHeight, gui.rightHeight)); + if (minecraft.gameMode != null && !minecraft.gameMode.canHurtPlayer()) { + //Same shift as done in Gui#renderSelectedItemName + targetShift -= 14; + } else if (gui.overlayMessageTime > 0) { + //If we are in survival though that means our thing will end up intersecting the subtitle text if there is any, + // so we need to check if there is, and if so shift our target further + targetShift += 14; + } + //Shift the rendering to be above the previous line + targetShift += 13; PoseStack pose = guiGraphics.pose(); pose.pushPose(); - pose.translate((screenWidth - componentWidth) / 2F, screenHeight - 60, 0); + pose.translate((screenWidth - componentWidth) / 2F, screenHeight - targetShift, 0); GuiUtils.drawBackdrop(guiGraphics, minecraft, 0, 0, componentWidth, color.a()); guiGraphics.drawString(font, scrollTextComponent, 0, 0, color.argb()); pose.popPose(); diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 865dd1cce73..1fe2b501fae 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,5 +1,7 @@ public net.minecraft.client.KeyMapping f_90817_ # isDown +public net.minecraft.client.gui.Gui f_92991_ # overlayMessageTime + public net.minecraft.client.gui.components.EditBox f_94097_ # canLoseFocus public net.minecraft.client.gui.components.EditBox m_94222_()Z # isEditable