package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.TimeUtils.formatted import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class InGameDateDisplay { private val config get() = SkyHanniMod.feature.gui.inGameDateConfig private var display = "" @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (!event.repeatSeconds(config.RefreshSeconds)) return checkDate() } private fun checkDate() { display = SkyBlockTime.now().formatted() } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return config.position.renderString(display, posLabel = "In-game Date Display") } fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled }