aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-29 03:32:18 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-29 03:32:18 +0100
commit3d8da1877afce737c7c924c0da80470247b927a7 (patch)
treeab0c58ca11df6c434f04a2dd36570b2667c13550 /src/main/java/at/hannibal2/skyhanni
parent226c1783c0214b62c3aeecb7f1372a8baf6e4a83 (diff)
downloadskyhanni-3d8da1877afce737c7c924c0da80470247b927a7.tar.gz
skyhanni-3d8da1877afce737c7c924c0da80470247b927a7.tar.bz2
skyhanni-3d8da1877afce737c7c924c0da80470247b927a7.zip
optimize CheckRenderEntityEvent and RenderItemTipEvent
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
index 384b0546d..67a4e1cab 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
@@ -5,6 +5,7 @@ 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.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
@@ -14,14 +15,26 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ItemTipHelper {
+ private val lastColorCacheTime = HashMap<String, Long>()
+ private val cache = HashMap<String, String>()
+
@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
+ val uuid = stack.getLore().joinToString { ", " }
+ val stackTip: String
+ if (lastColorCacheTime.getOrDefault(uuid, 0L) + 1000 > System.currentTimeMillis()) {
+ stackTip = cache[uuid]!!
+ } else {
+ val itemTipEvent = RenderItemTipEvent(stack)
+ itemTipEvent.postAndCatch()
+ stackTip = itemTipEvent.stackTip
+ cache[uuid] = stackTip
+ lastColorCacheTime[uuid] = System.currentTimeMillis()
+ }
+
if (stackTip.isEmpty()) return
GlStateManager.disableLighting()