diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-21 20:16:25 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-21 20:16:25 +0100 |
commit | 3bc18d545a395eb5a7d045d5163b51b2bc9a3278 (patch) | |
tree | 0c04a8e2ba855ef5a112bf05910b7131bc0484a1 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 779b62a4df0f90e03b670a2bf9c1c146e520aaf4 (diff) | |
download | skyhanni-3bc18d545a395eb5a7d045d5163b51b2bc9a3278.tar.gz skyhanni-3bc18d545a395eb5a7d045d5163b51b2bc9a3278.tar.bz2 skyhanni-3bc18d545a395eb5a7d045d5163b51b2bc9a3278.zip |
Fixed all Damage Indicator boss timers in Dungeons being off by a second.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
3 files changed, 25 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 1c50a65ab..1b4f1fc32 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -31,13 +31,15 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.LorenzUtils.put import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.LorenzUtils.ticks import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP @@ -55,6 +57,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.UUID import kotlin.math.max +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds class DamageIndicatorManager { @@ -168,9 +172,11 @@ class DamageIndicatorManager { var healthText = data.healthText val delayedStart = data.delayedStart - if (delayedStart != -1L && delayedStart > System.currentTimeMillis()) { - val delay = delayedStart - System.currentTimeMillis() - healthText = formatDelay(delay) + delayedStart?.let { + if (!it.isInPast()) { + val delay = it.timeUntil() + healthText = formatDelay(delay) + } } val location = if (data.dead && data.deathLocation != null) { @@ -297,14 +303,14 @@ class DamageIndicatorManager { damageCounter.oldDamages.removeIf { now > it.time + 5_000 } } - private fun formatDelay(delay: Long): String { + private fun formatDelay(delay: Duration): String { val color = when { - delay < 1_000 -> LorenzColor.DARK_PURPLE - delay < 3_000 -> LorenzColor.LIGHT_PURPLE + delay < 1.seconds -> LorenzColor.DARK_PURPLE + delay < 3.seconds -> LorenzColor.LIGHT_PURPLE else -> LorenzColor.WHITE } - val format = TimeUtils.formatDuration(delay, showMilliSeconds = true) + val format = delay.format(showMilliSeconds = true) return color.getChatColor() + format } @@ -646,15 +652,16 @@ class DamageIndicatorManager { //Laser phase if (config.enderSlayer.laserPhaseTimer && entity.ridingEntity != null) { - val ticksAlive = entity.ridingEntity.ticksExisted.toLong() //TODO more tests, more exact values, better logic? idk make this working perfectly pls - //val remainingTicks = 8 * 20 - ticksAlive - val remainingTicks = (7.4 * 20).toLong() - ticksAlive + val totalTimeAlive = 7.4.seconds + val ticksAlive = entity.ridingEntity.ticksExisted.ticks + val remainingTime = totalTimeAlive - ticksAlive + val formatDelay = formatDelay(remainingTime) if (config.enderSlayer.showHealthDuringLaser) { - entityData.nameSuffix = " §f" + formatDelay(remainingTicks * 50) + entityData.nameSuffix = " §f$formatDelay" } else { - return formatDelay(remainingTicks * 50) + return formatDelay } } @@ -789,7 +796,7 @@ class DamageIndicatorManager { val entityData = EntityData( entity, entityResult.ignoreBlocks, - entityResult.delayedStart, + entityResult.delayedStart?.asTimeMark(), entityResult.finalDungeonBoss, entityResult.bossType, foundTime = System.currentTimeMillis() diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt index 50e5b4547..7d8f52a74 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.entity.EntityLivingBase @@ -8,7 +9,7 @@ import net.minecraft.entity.EntityLivingBase class EntityData( val entity: EntityLivingBase, var ignoreBlocks: Boolean, - var delayedStart: Long, + var delayedStart: SimpleTimeMark?, val finalDungeonBoss: Boolean, val bossType: BossType, val damageCounter: DamageCounter = DamageCounter(), diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt index 4f6920293..2488b00ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.combat.damageindicator class EntityResult( - val delayedStart: Long = -1L, + val delayedStart: Long? = null, val ignoreBlocks: Boolean = false, val finalDungeonBoss: Boolean = false, val bossType: BossType = BossType.GENERIC_DUNGEON_BOSS, -)
\ No newline at end of file +) |