From 85d7ae90e5e299972f4ff288686d08bb671e72bf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:08:31 +0200 Subject: Fixed pet exp tooltip doesn't show in pet inventory or Hypixel profile viewer (right-click a player). --- .../skyhanni/features/misc/PetExpTooltip.kt | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt index 7a96c86d2..35ed88534 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt @@ -4,10 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils.indexOfFirst import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp +import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -25,11 +25,7 @@ class PetExpTooltip { val petExperience = itemStack.getPetExp()?.round(1) ?: return val name = itemStack.name ?: return - val index = event.toolTip.indexOfFirst( - "§5§o§7§eClick to summon!", - "§5§o§7§cClick to despawn!", - "§5§o§7§eRight-click to add this pet to", - ) ?: return + val index = findIndex(event.toolTip) ?: return val maxLevel = ItemUtils.maxPetLevel(name) val maxXp = maxPetExp(name) // lvl 100 legendary @@ -49,6 +45,21 @@ class PetExpTooltip { } } + private fun findIndex(toolTip: List): Int? { + var index = toolTip.indexOfFirst { it.contains("MAX LEVEL") } + if (index != -1) { + return index + 2 + } + + index = toolTip.indexOfFirst { it.contains("Progress to Level") } + if (index != -1) { + val offset = if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) 4 else 3 + return index + offset + } + + return null + } + private fun maxPetExp(petName: String) = when { petName.contains("Golden Dragon") && config.goldenDragon200 -> 210_255_385 // lvl 200 legendary petName.contains("Bingo") -> 5_624_785 // lvl 100 common -- cgit