aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-22 21:31:17 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-22 21:31:17 +0100
commitfc090691c5da91ad828b0ae712f7af306ddfd197 (patch)
tree7813866da4fc06d9a14bbabbf11953833570c4b3 /src
parenteffef951faef613c4cee852f7515810641b4e1f0 (diff)
downloadskyhanni-fc090691c5da91ad828b0ae712f7af306ddfd197.tar.gz
skyhanni-fc090691c5da91ad828b0ae712f7af306ddfd197.tar.bz2
skyhanni-fc090691c5da91ad828b0ae712f7af306ddfd197.zip
Fixed time until next area mini boss spawns being off by one second.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt
index f41f8ea0d..af7c4804d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt
@@ -14,19 +14,21 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.ignoreDerpy
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
-import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.monster.EntityBlaze
import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.entity.passive.EntityWolf
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
class AreaMiniBossFeatures {
private val config get() = SkyHanniMod.feature.combat.mobs
- private var lastTime = 0L
+ private var lastSpawnTime = SimpleTimeMark.farPast()
private var miniBossType: AreaMiniBossType? = null
- private var respawnCooldown = 11_000L
+ private var respawnCooldown = 11.seconds
@SubscribeEvent
fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) {
@@ -40,12 +42,12 @@ class AreaMiniBossFeatures {
if (!entity.hasMaxHealth(bossType.health, false, maxHealth)) continue
miniBossType = bossType
- val time = System.currentTimeMillis()
- val diff = time - lastTime
- if (diff in 5_000..20_000) {
+ val time = SimpleTimeMark.now()
+ val diff = time - lastSpawnTime
+ if (diff in 5.seconds..20.seconds) {
respawnCooldown = diff
}
- lastTime = time
+ lastSpawnTime = time
if (config.areaBossHighlight) {
val color = bossType.color.toColor().withAlpha(bossType.colorOpacity)
@@ -72,9 +74,11 @@ class AreaMiniBossFeatures {
}
private fun AreaMiniBossType.getTime(): String {
- val duration = System.currentTimeMillis() - lastTime
- val estimatedTime = respawnCooldown - duration % respawnCooldown
- val format = TimeUtils.formatDuration(estimatedTime, showMilliSeconds = true)
+ val spawnedSince = lastSpawnTime.passedSince()
+ if (respawnCooldown <= spawnedSince) return "§c?"
+
+ val estimatedTime = respawnCooldown - spawnedSince
+ val format = estimatedTime.format(showMilliSeconds = true)
return color.getChatColor() + format
}