Skip to content

Commit

Permalink
Using SimpleTimeMark in GardenYawAndPitch
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Aug 28, 2023
1 parent 30b3c5b commit 3d748cb
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)}",
Expand All @@ -50,6 +52,6 @@ class GardenYawAndPitch {

@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
lastChange = System.currentTimeMillis()
lastChange = SimpleTimeMark.farPast()
}
}

0 comments on commit 3d748cb

Please sign in to comment.