From d6df4f69afbe547a8e9373b0be4baa69d9e02a54 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 24 May 2023 20:42:02 +0200 Subject: Added Pet Candies Used number --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 + .../hannibal2/skyhanni/config/features/Misc.java | 5 +++ .../skyhanni/features/misc/PetCandyUsedDisplay.kt | 44 ++++++++++++++++++++++ .../skyhanni/utils/SkyBlockItemModifierUtils.kt | 4 ++ 4 files changed, 54 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index f7ec83601..555761bbe 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -276,6 +276,7 @@ class SkyHanniMod { loadModule(GardenVisitorDropStatistics) loadModule(SackDisplay()) loadModule(GardenStartLocation) + loadModule(PetCandyUsedDisplay()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 69cc53b4a..f5ad1513c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -411,6 +411,11 @@ public class Misc { @Expose public Position playerMovementSpeedPos = new Position(394, 124, false, true); + @Expose + @ConfigOption(name = "Pet Candy Used", desc = "Show numbers of pet candies used on a pet.") + @ConfigEditorBoolean + public boolean petCandyUsed = true; + @Expose @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt new file mode 100644 index 000000000..b09ec0896 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.features.misc + +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 net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class PetCandyUsedDisplay { + + @SubscribeEvent + fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { + val stack = event.stack ?: return + if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return + if (!SkyHanniMod.feature.misc.petCandyUsed) return + + val petCandyUsed = stack.getPetCandyUsed() ?: return + if (petCandyUsed == 0) return + + val stackTip = "§c$petCandyUsed" + + GlStateManager.disableLighting() + GlStateManager.disableDepth() + GlStateManager.disableBlend() + + val fontRenderer = event.fontRenderer + val x = event.x + 13 - fontRenderer.getStringWidth(stackTip) + val y = event.y + 1 + + val scale = 0.9 + GlStateManager.pushMatrix() + GlStateManager.translate(x.toFloat(), y.toFloat(), 0f) + GlStateManager.scale(scale, scale, scale) + fontRenderer.drawStringWithShadow(stackTip, 0f, 0f, 16777215) + val reverseScale = 1 / 0.7 + GlStateManager.scale(reverseScale, reverseScale, reverseScale) + GlStateManager.popMatrix() + + GlStateManager.enableLighting() + GlStateManager.enableDepth() + } + +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index dc59d832a..678772499 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name +import com.google.gson.JsonObject import net.minecraft.item.ItemStack object SkyBlockItemModifierUtils { @@ -23,6 +25,8 @@ object SkyBlockItemModifierUtils { fun ItemStack.getManaDisintegrators() = getAttributeInt("mana_disintegrator_count") + fun ItemStack.getPetCandyUsed() = ConfigManager.gson.fromJson(getExtraAttributes()?.getString("petInfo"), JsonObject::class.java)?.get("candyUsed")?.asInt + fun ItemStack.getMasterStars(): Int { val stars = mapOf( "➊" to 1, -- cgit