diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-01-16 19:02:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-16 19:02:43 +0100 |
commit | ec1aefdaae5490d264d4d932394896f861981045 (patch) | |
tree | 0efa87285ee1488a4de0dc7423e6115f0c0eb249 /src/main/java | |
parent | 69cfa25c720884f44d6ed99e24d2eb4176f09e37 (diff) | |
download | skyhanni-ec1aefdaae5490d264d4d932394896f861981045.tar.gz skyhanni-ec1aefdaae5490d264d4d932394896f861981045.tar.bz2 skyhanni-ec1aefdaae5490d264d4d932394896f861981045.zip |
Feature: Pet Item Display (#850)
Show Pet Items Xp Share core and Tier Boost as small icon next to the pet in an inventory. #850
Diffstat (limited to 'src/main/java')
3 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index f584951df..16499a6a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -248,6 +248,7 @@ import at.hannibal2.skyhanni.features.misc.PartyMemberOutlines import at.hannibal2.skyhanni.features.misc.PatcherSendCoordinates import at.hannibal2.skyhanni.features.misc.PetCandyUsedDisplay import at.hannibal2.skyhanni.features.misc.PetExpTooltip +import at.hannibal2.skyhanni.features.misc.PetItemDisplay import at.hannibal2.skyhanni.features.misc.PlayerChatSymbols import at.hannibal2.skyhanni.features.misc.PocketSackInASackDisplay import at.hannibal2.skyhanni.features.misc.QuickModMenuSwitch @@ -370,6 +371,7 @@ import org.apache.logging.log4j.Logger version = "0.23.Beta.8", ) class SkyHanniMod { + @Mod.EventHandler fun preInit(event: FMLPreInitializationEvent?) { checkIfNeuIsLoaded() @@ -578,6 +580,7 @@ class SkyHanniMod { loadModule(MinionCollectLogic()) loadModule(BetterSignEditing()) loadModule(PatcherSendCoordinates()) + loadModule(PetItemDisplay()) loadModule(EstimatedItemValue) loadModule(EstimatedWardrobePrice()) loadModule(ComposterInventoryNumbers()) @@ -757,6 +760,7 @@ class SkyHanniMod { } companion object { + const val MODID = "skyhanni" @JvmStatic diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java index 265c26a29..cf5cda654 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java @@ -5,7 +5,11 @@ import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; import io.github.moulberry.moulconfig.annotations.ConfigOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class PetConfig { @Expose @@ -28,4 +32,32 @@ public class PetConfig { @ConfigEditorBoolean @FeatureToggle public boolean hideAutopet = false; + + @Expose + @ConfigOption(name = "Show Pet Item", desc = "Specifies the pet items for which icons should be displayed next to pets.") + @ConfigEditorDraggableList + public List<PetItemsDisplay> petItemDisplay = new ArrayList<>(Arrays.asList( + PetItemsDisplay.XP_SHARE, + PetItemsDisplay.TIER_BOOST + )); + + public enum PetItemsDisplay { + XP_SHARE("§5⚘", "Exp Share", "PET_ITEM_EXP_SHARE"), + TIER_BOOST("§c●", "Tier Boost", "PET_ITEM_TIER_BOOST"), + ; + private final String str; + public final String icon; + public final String item; + + PetItemsDisplay(String icon, String name, String item) { + this.icon = icon; + this.item = item; + this.str = icon + " §ffor " + name; + } + + @Override + public String toString() { + return str; + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt new file mode 100644 index 000000000..35d0c81cc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt @@ -0,0 +1,28 @@ +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.RenderUtils.drawSlotText +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetItem +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class PetItemDisplay { + + private val configList get() = SkyHanniMod.feature.misc.pets.petItemDisplay + + @SubscribeEvent + fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { + val stack = event.stack ?: return + if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return + if (configList.isEmpty()) return + + val petItem = stack.getPetItem() ?: return + val icon = configList.firstOrNull { it.item == petItem }?.icon ?: return + + val x = event.x + 17 + val y = event.y - 1 + + event.drawSlotText(x, y, icon, .9f) + } +} |