diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 21:59:37 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 21:59:37 +0200 |
| commit | dd73bec2905517ebeaba5378e0a53ea228dffc33 (patch) | |
| tree | b5c31870d5da08161f079cd3ba5440fe79d5175b /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 3a2b67ef9adb2049e00f4d4e18aa8b5b681df2aa (diff) | |
| download | SkyHanni-dd73bec2905517ebeaba5378e0a53ea228dffc33.tar.gz SkyHanni-dd73bec2905517ebeaba5378e0a53ea228dffc33.tar.bz2 SkyHanni-dd73bec2905517ebeaba5378e0a53ea228dffc33.zip | |
fixed stats tuning display
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt | 52 |
1 files changed, 47 insertions, 5 deletions
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() } |
