diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-28 14:18:25 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-28 14:18:25 +0200 |
commit | 3d748cb79f3a1afa7f1a9b7d0561e5d7bb284a9b (patch) | |
tree | 6d10bb163b413f0a1ff1f294fdec9b597089a478 /src/main/java/at | |
parent | 30b3c5bfd4100c34eaea5b7dd15efc841a328d29 (diff) | |
download | skyhanni-3d748cb79f3a1afa7f1a9b7d0561e5d7bb284a9b.tar.gz skyhanni-3d748cb79f3a1afa7f1a9b7d0561e5d7bb284a9b.tar.bz2 skyhanni-3d748cb79f3a1afa7f1a9b7d0561e5d7bb284a9b.zip |
Using SimpleTimeMark in GardenYawAndPitch
Diffstat (limited to 'src/main/java/at')
-rwxr-xr-x | src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt | 10 |
1 files changed, 6 insertions, 4 deletions
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 |