aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
new file mode 100644
index 000000000..baa9fa75e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class ItemTipHelper {
+
+ @SubscribeEvent
+ fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
+ val stack = event.stack ?: return
+ if (!LorenzUtils.inSkyblock || stack.stackSize != 1) return
+
+ val itemTipEvent = RenderItemTipEvent(stack)
+ itemTipEvent.postAndCatch()
+ val stackTip = itemTipEvent.stackTip
+ if (stackTip.isEmpty()) return
+
+ GlStateManager.disableLighting()
+ 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
+
+ event.fontRenderer.drawStringWithShadow(stackTip, x.toFloat(), y.toFloat(), 16777215)
+ GlStateManager.enableLighting()
+ GlStateManager.enableDepth()
+ }
+} \ No newline at end of file