From e70a67bd5f4e0f0ca17bb1dd836a857b03c30cca Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:20:56 +0200 Subject: Feature: Ultimate Enchant Star (#2612) Co-authored-by: ItsEmpa --- .../config/features/inventory/InventoryConfig.java | 6 +++++ .../features/inventory/UltimateEnchantStar.kt | 28 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/UltimateEnchantStar.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 510f953ca..6e064ced6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -231,6 +231,12 @@ public class InventoryConfig { @FeatureToggle public boolean itemStars = false; + @Expose + @ConfigOption(name = "Ultimate Enchant Star", desc = "Show a star on Enchanted Books with an Ultimate Enchant.") + @ConfigEditorBoolean + @FeatureToggle + public boolean ultimateEnchantStar = false; + @Expose @ConfigOption(name = "Missing Tasks", desc = "Highlight missing tasks in the SkyBlock Level Guide inventory.") // TODO move( , "inventory.highlightMissingSkyBlockLevelGuide", "inventory.skyblockGuideConfig.highlightMissingSkyBlockLevelGuide") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/UltimateEnchantStar.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltimateEnchantStar.kt new file mode 100644 index 000000000..315d9822b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltimateEnchantStar.kt @@ -0,0 +1,28 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.events.RenderObject +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments +import net.minecraft.init.Items +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object UltimateEnchantStar { + + private val config get() = SkyHanniMod.feature.inventory + + @SubscribeEvent + fun onRenderItemTip(event: RenderItemTipEvent) { + if (!isEnabled()) return + if (event.stack.item != Items.enchanted_book) return + val enchants = event.stack.getEnchantments() ?: return + if (enchants.size != 1 || !enchants.keys.first().startsWith("ultimate_")) return + event.renderObjects += RenderObject("§d✦", -10, -10) + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.ultimateEnchantStar + +} -- cgit