diff options
author | HiZe_ <superhize@hotmail.com> | 2023-06-05 00:27:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 00:27:15 +0200 |
commit | fd248c963a4d08be55817cfc7683547f54f399f2 (patch) | |
tree | 5041db9cf3ee2e2b230883a943c95886d33f9beb /src/main | |
parent | 6a108796ed40747693277335b4d5de90c3ce7f0b (diff) | |
download | skyhanni-fd248c963a4d08be55817cfc7683547f54f399f2.tar.gz skyhanni-fd248c963a4d08be55817cfc7683547f54f399f2.tar.bz2 skyhanni-fd248c963a4d08be55817cfc7683547f54f399f2.zip |
Updated Sack-In-A-Sack display (#216)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Misc.java | 23 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt | 26 |
2 files changed, 43 insertions, 6 deletions
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 @@ -485,11 +503,6 @@ public class Misc { 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 public boolean configButtonOnPause = true; 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 (?<number>.*)".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 |