diff options
| author | Linnea Gräf <nea@nea.moe> | 2023-09-07 12:10:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-07 12:10:45 +0200 |
| commit | 1378e4e614d566cc0733647f0ae37ce85880fd8a (patch) | |
| tree | 90574e5ceb00ac442533bc50aa1d2b377385fe46 /src/main/java/at/hannibal2/skyhanni/features | |
| parent | cff2c91c06a44a6498288be38c3149d70b28beef (diff) | |
| download | skyhanni-1378e4e614d566cc0733647f0ae37ce85880fd8a.tar.gz skyhanni-1378e4e614d566cc0733647f0ae37ce85880fd8a.tar.bz2 skyhanni-1378e4e614d566cc0733647f0ae37ce85880fd8a.zip | |
It's time to punch wheat (#442)
It's time to punch wheat #442
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt new file mode 100644 index 000000000..eb8d330a0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt @@ -0,0 +1,77 @@ +package at.hannibal2.skyhanni.features.event.anniversary + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +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 +import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.TimeMark +import at.hannibal2.skyhanni.utils.renderables.Renderable +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraft.init.Items +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.time.Instant +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds + +object ActivePlayerTimer { + + var lastTimerReceived = TimeMark.never() + var lastTimeAlerted = TimeMark.never() + + var overlay: List<List<Any?>>? = null + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { + lastTimerReceived = TimeMark.now() + } + } + + fun isEnabled(): Boolean { + return SkyHanniMod.feature.misc.century.enableActiveTimer && + Instant.now().isBefore(SkyBlockTime(301).toInstant()) && + LorenzUtils.inSkyBlock + } + + + @SubscribeEvent + fun onRender(event: GuiRenderEvent.GameOverlayRenderEvent) { + SkyHanniMod.feature.misc.century.activeTimerPosition.renderStringsAndItems( + overlay ?: return, + posLabel = "300þ Anniversary Active Timer" + ) + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) { + overlay = null + return + } + val p = lastTimerReceived.passedTime() + val timeLeft = if (p > 20.minutes) { + 0.seconds + } else { + 20.minutes - p + } + if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedTime() > 5.minutes && SkyHanniMod.feature.misc.century.enableActiveAlert) { + SoundUtils.centuryActiveTimerAlert.playSound() + lastTimeAlerted = TimeMark.now() + } + overlay = + listOf( + listOf( + Renderable.itemStack(NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock)), + Renderable.string("§eTime Left: $timeLeft") + ) + ) + } + + +}
\ No newline at end of file |
