From 03f30aa94951bef366985c1eddb72922c255b2b3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 28 Sep 2022 21:59:37 +0200 Subject: fixed stats tuning display --- .../at/hannibal2/skyhanni/data/ItemTipHelper.kt | 52 +++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt index baa9fa75e..384b0546d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt @@ -1,9 +1,15 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.DrawScreenAfterEvent import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ItemTipHelper { @@ -22,12 +28,48 @@ class ItemTipHelper { GlStateManager.disableDepth() GlStateManager.disableBlend() - val x = event.x + 17 + itemTipEvent.offsetX - if (itemTipEvent.alignLeft) { - event.fontRenderer.getStringWidth(stackTip) - } else 0 - val y = event.y + 9 + itemTipEvent.offsetY + val fontRenderer = event.fontRenderer + val x = event.x + 17 - fontRenderer.getStringWidth(stackTip) + val y = event.y + 9 - event.fontRenderer.drawStringWithShadow(stackTip, x.toFloat(), y.toFloat(), 16777215) + fontRenderer.drawStringWithShadow(stackTip, x.toFloat(), y.toFloat(), 16777215) + GlStateManager.enableLighting() + GlStateManager.enableDepth() + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + fun onRenderInventoryItemOverlayPost(event: DrawScreenAfterEvent) { + if (!LorenzUtils.inSkyblock) return + + val gui = Minecraft.getMinecraft().currentScreen + if (gui !is GuiChest) return + + val guiLeft = (gui as AccessorGuiContainer).guiLeft + val guiTop = (gui as AccessorGuiContainer).guiTop + val fontRenderer = Minecraft.getMinecraft().fontRendererObj + + GlStateManager.disableLighting() + GlStateManager.disableDepth() + GlStateManager.disableBlend() + for (slot in gui.inventorySlots.inventorySlots) { + val stack = slot.stack ?: continue + if (stack.stackSize != 1) continue + + val itemTipEvent = RenderInventoryItemTipEvent(stack) + itemTipEvent.postAndCatch() + val stackTip = itemTipEvent.stackTip + if (stackTip.isEmpty()) continue + + val xDisplayPosition = slot.xDisplayPosition + val yDisplayPosition = slot.yDisplayPosition + + val x = guiLeft + xDisplayPosition + 17 + itemTipEvent.offsetX - if (itemTipEvent.alignLeft) { + fontRenderer.getStringWidth(stackTip) + } else 0 + val y = guiTop + yDisplayPosition + 9 + itemTipEvent.offsetY + + fontRenderer.drawStringWithShadow(stackTip, x.toFloat(), y.toFloat(), 16777215) + } GlStateManager.enableLighting() GlStateManager.enableDepth() } -- cgit