From cf039c7e215b26f78eeb468cd911c5d8f8586115 Mon Sep 17 00:00:00 2001 From: Clicks <58398364+CuzImClicks@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:26:42 +0200 Subject: Improvement: Option to hide all Tooltips inside of Excavator (#2579) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../mining/ExcavatorTooltipHiderConfig.java | 21 ++++++++++++++++ .../features/mining/FossilExcavatorConfig.java | 13 ++++------ .../fossilexcavator/ExcavatorTooltipHider.kt | 28 +++++++++++++++++++--- 3 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorTooltipHiderConfig.java (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorTooltipHiderConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorTooltipHiderConfig.java new file mode 100644 index 000000000..b1489ace8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/ExcavatorTooltipHiderConfig.java @@ -0,0 +1,21 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class ExcavatorTooltipHiderConfig { + + @Expose + @ConfigOption(name = "Hide Dirt", desc = "Hides tooltips of the Dirt inside of the Fossil Excavator.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideDirt = true; + + @Expose + @ConfigOption(name = "Hide Everything", desc = "Hide all tooltips inside of the Fossil Excavator.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideEverything = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java index 8dfb12854..8445afe53 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/FossilExcavatorConfig.java @@ -18,6 +18,11 @@ public class FossilExcavatorConfig { @Accordion public ExcavatorProfitTrackerConfig profitTracker = new ExcavatorProfitTrackerConfig(); + @Expose + @ConfigOption(name = "Excavator Tooltip Hider", desc = "") + @Accordion + public ExcavatorTooltipHiderConfig tooltipHider = new ExcavatorTooltipHiderConfig(); + @Expose @ConfigOption( name = "Profit per Excavation", @@ -36,12 +41,4 @@ public class FossilExcavatorConfig { @FeatureToggle public boolean glacitePowderStack = false; - @Expose - @ConfigOption( - name = "Hide Excavator Tooltips", - desc = "Hides tooltips of items inside of the Fossil Excavator." - ) - @ConfigEditorBoolean - @FeatureToggle - public boolean hideExcavatorTooltips = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorTooltipHider.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorTooltipHider.kt index 8b58402cd..0b0469b91 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorTooltipHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorTooltipHider.kt @@ -3,20 +3,42 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.player.inventory.ContainerLocalMenu import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ExcavatorTooltipHider { - private val config get() = SkyHanniMod.feature.mining.fossilExcavator + private val config get() = SkyHanniMod.feature.mining.fossilExcavator.tooltipHider + + /** + * REGEX-TEST: §6Dirt + */ + private val dirtPattern by RepoPattern.pattern( + "excavator.dirt.name", + "§6Dirt", + ) @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return + if (event.slot.inventory !is ContainerLocalMenu) return - event.cancel() + if (config.hideEverything) { + event.cancel() + return + } + + if (config.hideDirt) { + val isDirt = dirtPattern.matches(event.itemStack.name) + if (isDirt) { + event.cancel() + } + } } - fun isEnabled() = FossilExcavatorAPI.inInventory && !FossilExcavatorAPI.inExcavatorMenu && config.hideExcavatorTooltips + fun isEnabled() = FossilExcavatorAPI.inInventory && !FossilExcavatorAPI.inExcavatorMenu } -- cgit