blob: 028b0edbc6cec2281af2886f7f0b5da8f3872fe2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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
}
|