summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-22 22:47:58 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-22 22:47:58 +0200
commit51af64037d0422d4d6b603e1164e60cf4b50dda0 (patch)
tree7db56555251734d1df908248715c3d8e7ea7fcf0 /src/main/java/at/hannibal2/skyhanni/features
parentdd8b540be1eb5a97b26750b3c75f15d3af305e90 (diff)
downloadskyhanni-51af64037d0422d4d6b603e1164e60cf4b50dda0.tar.gz
skyhanni-51af64037d0422d4d6b603e1164e60cf4b50dda0.tar.bz2
skyhanni-51af64037d0422d4d6b603e1164e60cf4b50dda0.zip
Pet Experience Tooltip
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
new file mode 100644
index 000000000..c29387925
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
@@ -0,0 +1,50 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.ItemUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.indexOfFirst
+import at.hannibal2.skyhanni.utils.LorenzUtils.round
+import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp
+import at.hannibal2.skyhanni.utils.StringUtils
+import net.minecraftforge.event.entity.player.ItemTooltipEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class PetExpTooltip {
+ private val config get() = SkyHanniMod.feature.misc.petExperienceToolTip
+
+ @SubscribeEvent
+ fun onItemTooltipLow(event: ItemTooltipEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.petDisplay) return
+ if (!LorenzUtils.isShiftKeyDown() && !config.showAlways) return
+
+ val itemStack = event.itemStack ?: return
+ 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 maxLevel = ItemUtils.maxPetLevel(name)
+ val maxXp = if (maxLevel == 200) 210255385 else 25353230L
+
+ val percentage = petExperience / maxXp
+ val percentageFormat = LorenzUtils.formatPercentage(percentage)
+
+ event.toolTip.add(index, " ")
+ if (percentage >= 1) {
+ event.toolTip.add(index, "§7Total experience: §e${NumberUtil.format(petExperience)}")
+ } else {
+ val progressBar = StringUtils.progressBar(percentage)
+ event.toolTip.add(index, "$progressBar §e${petExperience.addSeparators()}§6/§e${NumberUtil.format(maxXp)}")
+ event.toolTip.add(index, "§7Progress to Level $maxLevel: §e$percentageFormat")
+ }
+ }
+}