Skip to content

Commit 9ee9a65

Browse files
committed
Fix rendering of things like emi's tooltips being at the wrong z level
1 parent 568d10f commit 9ee9a65

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/main/java/mekanism/client/gui/element/text/GuiTextField.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
202202
return super.isValidClickButton(button) && super.mouseClicked(mouseX, mouseY, button);
203203
}
204204

205-
//TODO - 1.21: Figure out why Guis with text fields seem to still have issues with https://github.com/emilyploszaj/emi/issues/480 when other ones don't
206-
// and it doesn't seem related to any of the code inside this draw background block
207-
// There is also an issue if enough gui windows are open, where EMI then renders the tooltip behind the third crafting window, which might be related
208205
@Override
209206
public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
210207
super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks);

src/main/java/mekanism/client/render/RenderTickHandler.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import net.minecraft.world.phys.BlockHitResult;
8080
import net.minecraft.world.phys.HitResult.Type;
8181
import net.minecraft.world.phys.Vec3;
82+
import net.neoforged.bus.api.EventPriority;
8283
import net.neoforged.bus.api.SubscribeEvent;
8384
import net.neoforged.neoforge.client.ClientHooks;
8485
import net.neoforged.neoforge.client.event.ClientTickEvent;
@@ -144,6 +145,26 @@ public static void guiOpening(ScreenEvent.Opening event) {
144145
}
145146
}
146147

148+
@SubscribeEvent(priority = EventPriority.HIGHEST)
149+
public void renderPostHighest(ScreenEvent.Render.Post event) {
150+
if (event.getScreen() instanceof GuiMekanism) {
151+
//Translate forward how far we go, so that things like recipe viewers draw far enough forward
152+
// Note: We will pop this in a listener at the lowest priority
153+
PoseStack pose = event.getGuiGraphics().pose();
154+
pose.pushPose();
155+
//Note: We translate forward an extra 200, so that items rendered in a gui window don't overlap EMI based tooltips
156+
pose.translate(0, 0, 200 + GuiMekanism.maxZOffset);
157+
}
158+
}
159+
160+
@SubscribeEvent(priority = EventPriority.LOWEST)
161+
public void renderPostLowest(ScreenEvent.Render.Post event) {
162+
if (event.getScreen() instanceof GuiMekanism) {
163+
//Matching pop to the push we did in renderPostHighest
164+
event.getGuiGraphics().pose().popPose();
165+
}
166+
}
167+
147168
public static void addTransparentRenderer(LazyRender render) {
148169
transparentRenderers.add(render);
149170
}

0 commit comments

Comments
 (0)