diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-14 15:55:23 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-14 15:55:23 +0200 |
commit | 4d1fcf5b07f14d40b78e25ecf7fd0eabf5733864 (patch) | |
tree | ac689388ce9d814e586ee87fdb2620a765e14112 /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 18e399281bbfed824bd5eca4faae1985adb3a435 (diff) | |
download | skyhanni-4d1fcf5b07f14d40b78e25ecf7fd0eabf5733864.tar.gz skyhanni-4d1fcf5b07f14d40b78e25ecf7fd0eabf5733864.tar.bz2 skyhanni-4d1fcf5b07f14d40b78e25ecf7fd0eabf5733864.zip |
Added Jacob's Contest Warning - Show a warning shortly before a new jacob contest starts.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
3 files changed, 25 insertions, 30 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 4be321a0f..c9eff68ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -16,12 +16,9 @@ import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.SoundUtils 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.* @@ -35,15 +32,6 @@ class GardenCropMilestoneDisplay { 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 @@ -307,7 +295,7 @@ class GardenCropMilestoneDisplay { if (millis < 5_900) { if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) { lastPlaySoundTime = System.currentTimeMillis() - sound.playSound() + SoundUtils.playBeepSound() } SendTitleHelper.sendTitle("§b${crop.cropName} $nextTier in $duration", 1_500) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 5786cae72..ec2bd680c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -8,6 +9,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -27,6 +29,7 @@ class GardenNextJacobContest { private val maxContestsPerYear = 124 private val contestDuration = 1_000 * 60 * 20 + private var lastWarningTime = 0L @SubscribeEvent fun onTabListUpdate(event: TabListUpdateEvent) { @@ -189,6 +192,7 @@ class GardenNextJacobContest { } else { list.add("§eNext: ") duration -= contestDuration + warn(duration, nextContest.crops) } for (crop in nextContest.crops) { list.add(" ") @@ -201,6 +205,19 @@ class GardenNextJacobContest { return list } + private fun warn(timeInMillis: Long, crops: List<CropType>) { + if (!config.nextJacobContestWarn) return + if (config.nextJacobContestWarnTime <= timeInMillis / 1000) return + + if (System.currentTimeMillis() < lastWarningTime) return + lastWarningTime = System.currentTimeMillis() + 60_000 * 40 + + val cropText = crops.joinToString("§7, ") { "§a${it.cropName}" } + LorenzUtils.chat("§e[SkyHanni] Next farming contest: $cropText") + SendTitleHelper.sendTitle("§eFarming Contest!", 5_000) + SoundUtils.playBeepSound() + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return @@ -218,7 +235,10 @@ class GardenNextJacobContest { if (!inCalendar) return if (display.isNotEmpty()) { - SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems(display, posLabel = "Load SkyBlock Calendar") + SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems( + display, + posLabel = "Load SkyBlock Calendar" + ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt index 66042304d..ab6c2420d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt @@ -7,26 +7,13 @@ import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.SoundUtils.playSound -import net.minecraft.client.audio.ISound -import net.minecraft.client.audio.PositionedSound +import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraft.item.ItemStack -import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class WrongFungiCutterWarning { private var mode = FungiMode.UNKNOWN - private var lastPlaySoundTime = 0L - private val sound = object : PositionedSound(ResourceLocation("random.orb")) { - init { - volume = 50f - repeat = false - repeatDelay = 0 - attenuationType = ISound.AttenuationType.NONE - } - } - @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { @@ -62,7 +49,7 @@ class WrongFungiCutterWarning { SendTitleHelper.sendTitle("§cWrong Fungi Cutter Mode!", 2_000) if (System.currentTimeMillis() > lastPlaySoundTime + 3_00) { lastPlaySoundTime = System.currentTimeMillis() - sound.playSound() + SoundUtils.playBeepSound() } } |