diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-14 23:01:25 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-14 23:01:25 +0100 |
commit | bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf (patch) | |
tree | d5250144c355cb7134d997b5d757b0abba8c7c15 /src | |
parent | 6a7d8d4b1878af419136727105e7660012fb4a6f (diff) | |
download | skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.tar.gz skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.tar.bz2 skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.zip |
Added Warn When Close
Diffstat (limited to 'src')
3 files changed, 50 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 6c8b941d4..69a2235f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -153,6 +153,16 @@ public class Garden { public boolean cropMilestoneProgress = true; @Expose + @ConfigOption( + name = "Warn When Close", + desc = "Warn with title and sound when the next crop milestone upgrade happens in 5 seconds. " + + "(Useful for switching to a different pet for leveling)") + @ConfigEditorBoolean + @ConfigAccordionId(id = 6) + public boolean cropMilestoneWarnClose = true; + + + @Expose @ConfigOption(name = "Display Position", desc = "") @ConfigEditorButton(runnableId = "cropMilestoneProgress", buttonText = "Edit") @ConfigAccordionId(id = 6) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index e245c77dd..702b5fb8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -23,7 +23,7 @@ class BarnFishingTimer { private var currentCount = 0 private var startTime = 0L - private var sound = object : PositionedSound(ResourceLocation("random.orb")) { + private val sound = object : PositionedSound(ResourceLocation("random.orb")) { init { volume = 50f repeat = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index 156f3dd59..1913406e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -2,12 +2,17 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.SoundUtils.playSound import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraft.client.audio.ISound +import net.minecraft.client.audio.PositionedSound import net.minecraft.item.ItemStack +import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.* @@ -17,9 +22,34 @@ class GardenCropMilestoneDisplay { private val cultivatingData = mutableMapOf<String, Int>() private val config get() = SkyHanniMod.feature.garden private val bestCropTime = GardenBestCropTime() +// val cropMilestoneLevelUpPattern = Pattern.compile(" §r§b§lGARDEN MILESTONE §3(.*) §8XXIII➜§3(.*)") + + private val sound = object : PositionedSound(ResourceLocation("random.orb")) { + init { + volume = 50f + repeat = false + repeatDelay = 0 + attenuationType = ISound.AttenuationType.NONE + } + } + private var lastPlaySoundTime = 0L private var needsInventory = false +// @SubscribeEvent +// fun onChatMessage(event: LorenzChatEvent) { +// if (!isEnabled()) return +// if (config.cropMilestoneWarnClose) { +// val matcher = cropMilestoneLevelUpPattern.matcher(event.message) +// if (matcher.matches()) { +// val cropType = matcher.group(1) +// val newLevel = matcher.group(2).romanToDecimalIfNeeded() +// LorenzUtils.debug("found milestone messsage!") +// SendTitleHelper.sendTitle("§b$cropType $newLevel", 1_500) +// } +// } +// } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return @@ -172,6 +202,15 @@ class GardenCropMilestoneDisplay { val millis = missingTimeSeconds * 1000 bestCropTime.timeTillNextCrop[it] = millis val duration = TimeUtils.formatDuration(millis) + if (config.cropMilestoneWarnClose) { + if (millis < 5_900) { + if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) { + lastPlaySoundTime = System.currentTimeMillis() + sound.playSound() + } + SendTitleHelper.sendTitle("§b$it $nextTier in $duration", 1_500) + } + } progressDisplay.add(Collections.singletonList("§7in §b$duration")) val format = LorenzUtils.formatInteger(averageSpeedPerSecond * 60) |