From 3d748cb79f3a1afa7f1a9b7d0561e5d7bb284a9b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:18:25 +0200 Subject: Using SimpleTimeMark in GardenYawAndPitch --- .../at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt index ee80ab77b..342812c39 100755 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt @@ -6,12 +6,14 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class GardenYawAndPitch { private val config get() = SkyHanniMod.feature.garden.yawPitchDisplay - private var lastChange = 0L + private var lastChange = SimpleTimeMark.farPast() private var lastYaw = 0f private var lastPitch = 0f @@ -30,12 +32,12 @@ class GardenYawAndPitch { val pitch = player.rotationPitch if (yaw != lastYaw || pitch != lastPitch) { - lastChange = System.currentTimeMillis() + lastChange = SimpleTimeMark.now() } lastYaw = yaw lastPitch = pitch - if (!config.showAlways && System.currentTimeMillis() > lastChange + (config.timeout * 1000)) return + if (!config.showAlways && lastChange.passedSince() > config.timeout.seconds) return val displayList = listOf( "§aYaw: §f${yaw.round(config.yawPrecision)}", @@ -50,6 +52,6 @@ class GardenYawAndPitch { @SubscribeEvent fun onGardenToolChange(event: GardenToolChangeEvent) { - lastChange = System.currentTimeMillis() + lastChange = SimpleTimeMark.farPast() } } \ No newline at end of file -- cgit