Skip to content

Commit 9ef1764

Browse files
committed
gui fixes
1 parent 7bb38e9 commit 9ef1764

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Diff for: src/main/java/com/solegendary/reignofnether/hud/Button.java

+7
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
161161
int xyDiff = (DEFAULT_ICON_SIZE - iconSize) / 2;
162162

163163
if (this.frameResource != null) {
164+
guiGraphics.pose().translate(0,0,1);
164165
MyRenderer.renderIconFrameWithBg(guiGraphics, this.frameResource, x + xyDiff, y + xyDiff, iconFrameSize, 0x64000000);
165166
}
166167

167168
if (bgIconResource != null) {
169+
guiGraphics.pose().translate(0,0,1);
168170
MyRenderer.renderIcon(
169171
guiGraphics,
170172
bgIconResource,
@@ -175,6 +177,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
175177
}
176178
// item/unit icon
177179
if (iconResource != null) {
180+
guiGraphics.pose().translate(0,0,1);
178181
MyRenderer.renderIcon(
179182
guiGraphics,
180183
iconResource,
@@ -186,6 +189,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
186189
if (this.hotkey != null) {
187190
String hotkeyStr = hotkey.buttonLabel;
188191
hotkeyStr = hotkeyStr.substring(0,Math.min(3, hotkeyStr.length()));
192+
guiGraphics.pose().translate(0,0,1);
189193
guiGraphics.drawCenteredString( MC.font,
190194
hotkeyStr,
191195
x + iconSize + 8 - (hotkeyStr.length() * 4),
@@ -202,6 +206,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
202206

203207
if (frameResource != null) {
204208
ResourceLocation iconFrameSelectedResource = new ResourceLocation(ReignOfNether.MOD_ID, "textures/hud/icon_frame_selected.png");
209+
guiGraphics.pose().translate(0,0,1);
205210
MyRenderer.renderIcon(
206211
guiGraphics,
207212
iconFrameSelectedResource,
@@ -212,6 +217,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
212217
}
213218
// light up on hover
214219
if (isEnabled.get() && isMouseOver(mouseX, mouseY)) {
220+
guiGraphics.pose().translate(0,0,1);
215221
guiGraphics.fill( // x1,y1, x2,y2,
216222
x + xyDiff, y + xyDiff,
217223
x + xyDiff + iconFrameSize,
@@ -224,6 +230,7 @@ public void render(GuiGraphics guiGraphics, int x, int y, int mouseX, int mouseY
224230
if (!isEnabled.get())
225231
greyHeightPx = 0;
226232

233+
guiGraphics.pose().translate(0,0,1);
227234
guiGraphics.fill( // x1,y1, x2,y2,
228235
x + xyDiff,
229236
y + xyDiff + greyHeightPx,

Diff for: src/main/java/com/solegendary/reignofnether/mixin/ForgeGuiMixin.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.solegendary.reignofnether.mixin;
22

3+
import com.mojang.blaze3d.platform.Window;
34
import com.mojang.blaze3d.vertex.PoseStack;
45
import com.solegendary.reignofnether.orthoview.OrthoviewClientEvents;
56
import net.minecraft.client.Minecraft;
67
import net.minecraft.client.gui.Gui;
78
import net.minecraft.client.gui.GuiGraphics;
89
import net.minecraft.client.renderer.entity.ItemRenderer;
10+
import net.minecraft.util.Mth;
911
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
1012
import net.minecraftforge.client.gui.overlay.ForgeGui;
1113
import net.minecraftforge.common.MinecraftForge;
@@ -35,11 +37,14 @@ protected void renderChat(int width, int height, GuiGraphics guiGraphics, Callba
3537
ci.cancel();
3638

3739
this.minecraft.getProfiler().push("chat");
38-
CustomizeGuiOverlayEvent.Chat event = new CustomizeGuiOverlayEvent.Chat(this.minecraft.getWindow(), guiGraphics, this.minecraft.getFrameTime(), 0, height - 48);
40+
Window window = this.minecraft.getWindow();
41+
CustomizeGuiOverlayEvent.Chat event = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, this.minecraft.getFrameTime(), 0, height - 40);
3942
MinecraftForge.EVENT_BUS.post(event);
4043
guiGraphics.pose().pushPose();
41-
guiGraphics.pose().translate(event.getPosX(), event.getPosY() - 50, 0.0);
42-
this.chat.render(guiGraphics, this.tickCount, 0, 0);
44+
guiGraphics.pose().translate((double)event.getPosX(), (double)(event.getPosY() - height - 15) / this.chat.getScale(), 0.0);
45+
int mouseX = Mth.floor(this.minecraft.mouseHandler.xpos() * (double)window.getGuiScaledWidth() / (double)window.getScreenWidth());
46+
int mouseY = Mth.floor(this.minecraft.mouseHandler.ypos() * (double)window.getGuiScaledHeight() / (double)window.getScreenHeight());
47+
this.chat.render(guiGraphics, this.tickCount, mouseX, mouseY);
4348
guiGraphics.pose().popPose();
4449
this.minecraft.getProfiler().pop();
4550
}

0 commit comments

Comments
 (0)