diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-05-26 23:02:48 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-26 15:02:48 +0200 |
commit | f67af16eacb6cdf3598183d473f072d123ef8a25 (patch) | |
tree | 62d11d0f5191d48eee31a630a0b054baeb89a509 /src/main/java/at/hannibal2/skyhanni/features/combat | |
parent | 29657e24412baa7be9a1681593593368f92de26f (diff) | |
download | skyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.tar.gz skyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.tar.bz2 skyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.zip |
Backend: Convert stuff to SimpleTimeMark (#1777)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/combat')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt index 3d77e214a..ac2496f18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt @@ -20,6 +20,7 @@ import net.minecraft.network.play.server.S2APacketParticles import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds class SpawnTimers { @@ -40,13 +41,13 @@ class SpawnTimers { private var arachneSpawnTime = SimpleTimeMark.farPast() private var saveNextTickParticles = false private var particleCounter = 0 - private var tickTime: Long = 0 - private var searchTime: Long = 0 + private var lastTickTime = SimpleTimeMark.farPast() + private var searchTime = SimpleTimeMark.farPast() @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - searchTime = 0 - tickTime = 0 + searchTime = SimpleTimeMark.farPast() + lastTickTime = SimpleTimeMark.farPast() particleCounter = 0 saveNextTickParticles = false arachneSpawnTime = SimpleTimeMark.farPast() @@ -70,9 +71,9 @@ class SpawnTimers { if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) { if (arachneCrystalPattern.matches(message)) { saveNextTickParticles = true - searchTime = System.currentTimeMillis() + searchTime = SimpleTimeMark.now() particleCounter = 0 - tickTime = 0L + lastTickTime = SimpleTimeMark.farPast() } else arachneSpawnTime = SimpleTimeMark.now() + 19.seconds } } @@ -81,11 +82,11 @@ class SpawnTimers { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onPacketReceive(event: PacketEvent.ReceiveEvent) { if (!saveNextTickParticles) return - if (System.currentTimeMillis() <= searchTime + 3000) return + if (searchTime.passedSince() < 3.seconds) return - if (particleCounter == 0 && tickTime == 0L) tickTime = System.currentTimeMillis() + if (particleCounter == 0 && lastTickTime.isFarPast()) lastTickTime = SimpleTimeMark.now() - if (System.currentTimeMillis() > tickTime + 60) { + if (lastTickTime.passedSince() > 60.milliseconds) { arachneSpawnTime = if (particleCounter <= 20) { SimpleTimeMark.now() + 21.seconds } else { |