From fd248c963a4d08be55817cfc7683547f54f399f2 Mon Sep 17 00:00:00 2001 From: HiZe_ Date: Mon, 5 Jun 2023 00:27:15 +0200 Subject: Updated Sack-In-A-Sack display (#216) --- .../hannibal2/skyhanni/config/features/Misc.java | 23 ++++++++++++++----- .../features/misc/PocketSackInASackDisplay.kt | 26 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 6 deletions(-) (limited to 'src') 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 0402c1ae2..d55463419 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -423,6 +423,24 @@ public class Misc { public boolean vipVisits = true; } + @ConfigOption(name = "Pocket Sack-In-A-Sack", desc = "") + @Accordion + @Expose + public PocketSackInASack pocketSackInASack = new PocketSackInASack(); + + public static class PocketSackInASack { + + @Expose + @ConfigOption(name = "Pocket Sack-In-A-Sack", desc = "Show numbers of Pocket Sack-In-A-Sack applied on a sack.") + @ConfigEditorBoolean + public boolean showApplied = false; + + @Expose + @ConfigOption(name = "Replace In Lore", desc = "Replace how text is displayed in lore.\nShow §eis stitched with 2/3...\n§7Instead of §eis stitched with two...") + @ConfigEditorBoolean + public boolean replaceLore = false; + } + @Expose @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.") @ConfigEditorBoolean @@ -484,11 +502,6 @@ public class Misc { @ConfigEditorBoolean public boolean serverRestartTitle = true; - @Expose - @ConfigOption(name = "Pocket Sack-In-A-Sack", desc = "Show numbers of Pocket Sack-In-A-Sack applied on a sack.") - @ConfigEditorBoolean - public boolean sackInASackApplied = false; - @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/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt index 3c4e4849c..5d851eb56 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt @@ -2,18 +2,24 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PocketSackInASackDisplay { + private val config get() = SkyHanniMod.feature.misc.pocketSackInASack + private val valPattern = "§5§o§7This sack is stitched with (?.*)".toPattern() + @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { val stack = event.stack ?: return if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return - if (!SkyHanniMod.feature.misc.sackInASackApplied) return + if (!config.showApplied) return val pocketSackInASackApplied = stack.getAppliedPocketSackInASack() ?: return val stackTip = "§a$pocketSackInASackApplied" @@ -38,4 +44,22 @@ class PocketSackInASackDisplay { GlStateManager.enableLighting() GlStateManager.enableDepth() } + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent){ + if (!config.replaceLore) return + if (!ItemUtils.isSack(event.itemStack.displayName)) return + val it = event.toolTip.listIterator() + for (line in it){ + valPattern.matchMatcher(line){ + val replace = when (group("number")){ + "a" -> "§c1" + "two" -> "§62" + "three" -> "§a3" + else -> "0" + } + it.set(line.replace(Regex("\\b${group("number")}\\b"), "$replace§7/§b3")) + } + } + } } \ No newline at end of file -- cgit