From 942dd629efbf12183b1c5f5a966c36d4b0647a6b Mon Sep 17 00:00:00 2001 From: nea Date: Sun, 7 May 2023 12:22:36 +0200 Subject: Add fishing particle highlighter Currently does not work when sneaking or when the bobber moves too much, since the position desyncs with the server --- src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt (limited to 'src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt new file mode 100644 index 0000000..5196606 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt @@ -0,0 +1,15 @@ +package moe.nea.notenoughupdates.util + +import kotlin.time.Duration +import kotlin.time.ExperimentalTime +import kotlin.time.TimeSource + +@OptIn(ExperimentalTime::class) +class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) { + fun passedTime() = timeMark?.elapsedNow() ?: Duration.INFINITE + + companion object { + fun now() = TimeMark(TimeSource.Monotonic.markNow()) + fun farPast() = TimeMark(null) + } +} -- cgit