Skip to content

Commit

Permalink
Make our status overlay rendering respect left and right height of gu…
Browse files Browse the repository at this point in the history
…i overlays
  • Loading branch information
pupnewfster committed Jul 14, 2023
1 parent 19dcdc3 commit 27b0084
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/mekanism/client/ClientRegistration.java
Expand Up @@ -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);
}

Expand Down
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions 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

Expand Down

0 comments on commit 27b0084

Please sign in to comment.