From ff6da4e141f94bab3a13625b072286fb75a7a430 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:26:32 +0200 Subject: Fixed item rarity problems with glowing dropped items and made code more readable --- .../features/misc/items/GlowingDroppedItems.kt | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt index ac83276a1..dc63bef64 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -27,20 +28,24 @@ class GlowingDroppedItems { @SubscribeEvent fun onRenderEntityOutlines(event: RenderEntityOutlineEvent) { if (isEnabled() && event.type === RenderEntityOutlineEvent.Type.XRAY) { - event.queueEntitiesToOutline(getEntityOutlineColor) + event.queueEntitiesToOutline { getEntityOutlineColor(it) } } } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - private val getEntityOutlineColor: (entity: Entity) -> Int? = { entity -> - if (entity is EntityItem && !shouldHideShowcaseItem(entity)) { - val rarity = entity.entityItem.getItemRarityOrNull() + private fun getEntityOutlineColor(entity: Entity): Int? { + val item = entity as? EntityItem ?: return null + if (shouldHideShowcaseItem(entity)) return null - if (config.highlightFishingBait || entity.entityItem.name?.endsWith(" Bait") != true) { - rarity?.color?.toColor()?.rgb - } else null - } else null + val entityItem = item.entityItem + if (!config.highlightFishingBait && entityItem.name?.endsWith(" Bait") == true) { + return null + } + + entityItem.getInternalNameOrNull() ?: return null + val rarity = entityItem.getItemRarityOrNull() + return rarity?.color?.toColor()?.rgb } private fun isShowcaseArea() = -- cgit