From fac011b67ed2182f32541b4e1c340a43b7c02af8 Mon Sep 17 00:00:00 2001 From: slprime <31038811+slprime@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:20:32 +0200 Subject: [PATCH] Fix Zoom Position (#554) Co-authored-by: slprime --- src/main/java/codechicken/nei/ItemZoom.java | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/codechicken/nei/ItemZoom.java b/src/main/java/codechicken/nei/ItemZoom.java index 5df0d9662..cbf160f74 100644 --- a/src/main/java/codechicken/nei/ItemZoom.java +++ b/src/main/java/codechicken/nei/ItemZoom.java @@ -1,9 +1,5 @@ package codechicken.nei; -import static codechicken.lib.gui.GuiDraw.drawStringC; -import static codechicken.lib.gui.GuiDraw.fontRenderer; -import static codechicken.lib.gui.GuiDraw.getMousePosition; - import java.awt.Point; import java.util.List; @@ -15,6 +11,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; +import codechicken.lib.gui.GuiDraw; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; import codechicken.nei.recipe.StackInfo; @@ -65,13 +62,14 @@ public void draw(int mx, int my) { GuiContainerManager.enable2DRender(); if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.showName")) { - String dispalyName = NEIClientUtils.cropText(fontRenderer, this.displayName, this.availableAreaWidth); - drawStringC( + String dispalyName = NEIClientUtils + .cropText(GuiDraw.fontRenderer, this.displayName, this.availableAreaWidth); + GuiDraw.drawStringC( dispalyName, (int) ((this.xPosition + size / 2) * screenScale), (int) ((this.yPosition + size) * screenScale) + shiftText, NEIClientConfig.getSetting("inventory.itemzoom.nameColor").getHexValue()); - shiftText += fontRenderer.FONT_HEIGHT; + shiftText += GuiDraw.fontRenderer.FONT_HEIGHT; } if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled") @@ -80,15 +78,16 @@ public void draw(int mx, int my) { if (keyName != null) { String helpText = NEIClientUtils.translate("itemzoom.toggle", keyName); - List lines = fontRenderer.listFormattedStringToWidth(helpText, this.availableAreaWidth); + List lines = GuiDraw.fontRenderer + .listFormattedStringToWidth(helpText, this.availableAreaWidth); for (String line : lines) { - drawStringC( + GuiDraw.drawStringC( line, (int) ((this.xPosition + size / 2) * screenScale), (int) ((this.yPosition + size) * screenScale) + 10 + shiftText, 0x66555555); - shiftText += fontRenderer.FONT_HEIGHT; + shiftText += GuiDraw.fontRenderer.FONT_HEIGHT; } } } @@ -103,17 +102,17 @@ public void resize(GuiContainer gui) { if (stack != null && (!NEIClientConfig.getBooleanSetting("inventory.itemzoom.onlySolid") || Block.getBlockFromItem(stack.getItem()).getMaterial().isSolid())) { final float screenScale = 1.0f / getScreenScale(); - final float availableAreaWidth = (gui.width - (gui.xSize + gui.width) / 2) * screenScale; + final float availableAreaWidth = (gui.width - gui.xSize) / 2 * screenScale; final float availableAreaHeight = gui.height * screenScale; - final Point mouse = getMousePosition(); + final Point mouse = GuiDraw.getMousePosition(); this.scale = Math.round(getZoomAmount(gui) * getPointSize(gui) / SLOT_SIZE); this.yPosition = (availableAreaHeight - this.scale * SLOT_SIZE) / 2; this.xPosition = (availableAreaWidth - this.scale * SLOT_SIZE) / 2; this.availableAreaWidth = (int) (availableAreaWidth / screenScale); - if (ItemPanels.bookmarkPanel.contains(mouse.x, mouse.y)) { - this.xPosition += (gui.guiLeft + gui.xSize) * screenScale;; + if (availableAreaWidth / screenScale >= mouse.x) { + this.xPosition = gui.width * screenScale - availableAreaWidth; } try { @@ -166,7 +165,7 @@ private void decreaseZoom(GuiContainer gui) { private ItemStack getStackMouseOver(GuiContainer gui) { if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.neiOnly")) { - final Point mouse = getMousePosition(); + final Point mouse = GuiDraw.getMousePosition(); ItemStack stack = ItemPanels.itemPanel.getStackMouseOver(mouse.x, mouse.y); if (stack == null) {