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/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 6a7d8d4b1878af419136727105e7660012fb4a6f (diff) | |
download | skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.tar.gz skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.tar.bz2 skyhanni-bbc55fb133197bfbe3bbf1748b4d33ce218fe1bf.zip |
Added Warn When Close
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 39 |
1 files changed, 39 insertions, 0 deletions
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) |