diff --git a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java index 6b3c5ff3..6b1e374d 100644 --- a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java +++ b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java @@ -349,6 +349,10 @@ private Panel getDoubleClickTarget() { return modalPanels.isEmpty() ? this : modalPanels.peekFirst(); } + public int getMaxZLevel() { + return modalPanels.stream().map(ModalPanel::getExtraZlevel).max(Integer::compare).orElse(0); + } + @Override public boolean mousePressed(MouseButton button) { if (button == MouseButton.BACK) { diff --git a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/MenuScreenWrapper.java b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/MenuScreenWrapper.java index cb3be54f..2786309c 100644 --- a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/MenuScreenWrapper.java +++ b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/MenuScreenWrapper.java @@ -137,15 +137,16 @@ protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { wrappedGui.addMouseOverText(tooltipList); + int zLevel = wrappedGui.getMaxZLevel() + 100; + + graphics.pose().pushPose(); if (!tooltipList.shouldRender()) { wrappedGui.getIngredientUnderMouse().ifPresent(underMouse -> { if (underMouse.tooltip()) { var ingredient = underMouse.ingredient(); if (ingredient instanceof ItemStack stack && !stack.isEmpty()) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, tooltipList.zOffsetItemTooltip); + graphics.pose().translate(0, 0, zLevel); graphics.renderTooltip(theme.getFont(), (ItemStack) ingredient, mouseX, mouseY); - graphics.pose().popPose(); } } }); @@ -154,12 +155,12 @@ protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { .reduce((c1, c2) -> c1.copy().append("\n").append(c2)) .orElse(Component.empty()) ); - graphics.pose().translate(0, 0, 600); + graphics.pose().translate(0, 0, zLevel); graphics.setColor(1f, 1f, 1f, 0.8f); graphics.renderTooltip(theme.getFont(), lines, DefaultTooltipPositioner.INSTANCE, mouseX, Math.max(mouseY, 18)); graphics.setColor(1f, 1f, 1f, 1f); - graphics.pose().translate(0, 0, -600); } + graphics.pose().popPose(); tooltipList.reset(); diff --git a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/ScreenWrapper.java b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/ScreenWrapper.java index 0d410166..4b197671 100644 --- a/common/src/main/java/dev/ftb/mods/ftblibrary/ui/ScreenWrapper.java +++ b/common/src/main/java/dev/ftb/mods/ftblibrary/ui/ScreenWrapper.java @@ -119,25 +119,26 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTi wrappedGui.addMouseOverText(tooltipList); + int zLevel = wrappedGui.getMaxZLevel() + 100; + + graphics.pose().pushPose(); if (!tooltipList.shouldRender()) { wrappedGui.getIngredientUnderMouse().ifPresent(underMouse -> { if (underMouse.tooltip()) { var ingredient = underMouse.ingredient(); if (ingredient instanceof ItemStack stack && !stack.isEmpty()) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, tooltipList.zOffsetItemTooltip); + graphics.pose().translate(0, 0, zLevel); graphics.renderTooltip(theme.getFont(), (ItemStack) ingredient, mouseX, mouseY); - graphics.pose().popPose(); } } }); } else { - graphics.pose().translate(0, 0, 600); + graphics.pose().translate(0, 0, zLevel); graphics.setColor(1f, 1f, 1f, 0.8f); graphics.renderTooltip(theme.getFont(), tooltipList.getLines(), Optional.empty(), mouseX, Math.max(mouseY, 18)); graphics.setColor(1f, 1f, 1f, 1f); - graphics.pose().translate(0, 0, -600); } + graphics.pose().popPose(); tooltipList.reset(); } diff --git a/common/src/main/java/dev/ftb/mods/ftblibrary/util/TooltipList.java b/common/src/main/java/dev/ftb/mods/ftblibrary/util/TooltipList.java index 8af9b9f7..91c5dfec 100644 --- a/common/src/main/java/dev/ftb/mods/ftblibrary/util/TooltipList.java +++ b/common/src/main/java/dev/ftb/mods/ftblibrary/util/TooltipList.java @@ -9,8 +9,6 @@ public class TooltipList { private final List lines = new ArrayList<>(); - public int zOffset = 950; - public int zOffsetItemTooltip = 0; public int backgroundColor = 0xC0100010; public int borderColorStart = 0x505000FF; public int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000; @@ -24,8 +22,6 @@ public boolean shouldRender() { public void reset() { lines.clear(); - zOffset = 950; - zOffsetItemTooltip = 0; backgroundColor = 0xC0100010; borderColorStart = 0x505000FF; borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000; diff --git a/gradle.properties b/gradle.properties index be95d386..d9c9e3fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.daemon=false # Mod mod_id=ftblibrary readable_name=FTB Library -mod_version=2100.1.1 +mod_version=2100.1.2 mod_author=FTB Team # Maven @@ -16,12 +16,12 @@ minecraft_version=1.21 # Deps forge_version=49.0.31 -neoforge_version=21.0.14-beta +neoforge_version=21.0.40-beta neoforge_loader_version=4 fabric_loader_version=0.15.11 fabric_api_version=0.100.1+1.21 -architectury_version=13.0.1 +architectury_version=13.0.2 # There are too many of these now rei_version=16.0.729