diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-29 15:19:52 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-29 15:19:52 +0200 |
commit | cd03dcaacb864b0d181040c48dcd23f7e7ccdd68 (patch) | |
tree | cd479d871b7d328ec8d964eb2b18cb1732c2c8bc /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | 9ed54102a74dd983faccd920cd0f3415f7d24425 (diff) | |
download | skyhanni-cd03dcaacb864b0d181040c48dcd23f7e7ccdd68.tar.gz skyhanni-cd03dcaacb864b0d181040c48dcd23f7e7ccdd68.tar.bz2 skyhanni-cd03dcaacb864b0d181040c48dcd23f7e7ccdd68.zip |
Added ItemStack.cachedData to store candyUsed and heldItem
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt index ec98aa655..5cfcd881d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt @@ -4,25 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderItemEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetCandyUsed -import com.google.common.cache.CacheBuilder import net.minecraft.client.renderer.GlStateManager -import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.concurrent.TimeUnit class PetCandyUsedDisplay { - private var cache = - CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.SECONDS).build<ItemStack, Int>() - - private fun getCachedPetCandyUsed(stack: ItemStack): Int? { - cache.getIfPresent(stack)?.let { - if (it == -1) return null - return it - } - val candyUsed = stack.getPetCandyUsed() - cache.put(stack, candyUsed ?: -1) - return candyUsed - } @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { @@ -31,8 +16,7 @@ class PetCandyUsedDisplay { if (!SkyHanniMod.feature.misc.petCandyUsed) return - val petCandyUsed = getCachedPetCandyUsed(stack) ?: return -// val petCandyUsed = stack.getPetCandyUsed() ?: return + val petCandyUsed = stack.getPetCandyUsed() ?: return if (petCandyUsed == 0) return val stackTip = "§c$petCandyUsed" |