diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-13 20:25:33 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-13 20:25:33 +0100 |
commit | a35b093c39c9dce7697d1daacecab199a44c9f40 (patch) | |
tree | 4c8a5b86e0ab38b898c28c49ba6509294070f006 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 5a75b69da9f8b1cfa7705c6d6b9850d72b5a0ab6 (diff) | |
download | skyhanni-a35b093c39c9dce7697d1daacecab199a44c9f40.tar.gz skyhanni-a35b093c39c9dce7697d1daacecab199a44c9f40.tar.bz2 skyhanni-a35b093c39c9dce7697d1daacecab199a44c9f40.zip |
Show the time it takes to kill the Slayer boss.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
10 files changed, 66 insertions, 64 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt index 0a99f942a..a60af8ec8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt @@ -5,10 +5,11 @@ import at.hannibal2.skyhanni.events.BazaarUpdateEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.text.DecimalFormat class BazaarUpdateTimer { private var lastBazaarUpdateTime = 0L @@ -24,13 +25,11 @@ class BazaarUpdateTimer { if (!isEnabled()) return if (!BazaarApi.isBazaarInventory(InventoryUtils.openInventoryName())) return - val duration = System.currentTimeMillis() - lastBazaarUpdateTime - val durationSeconds = duration.toDouble() / 1000 - val nextUpdateIn = 10 - durationSeconds - val format = if (nextUpdateIn < 0) { + val duration = 10_000 - (System.currentTimeMillis() - lastBazaarUpdateTime) + val format = if (duration < 0) { "Updating" } else { - DecimalFormat("0.0").format(nextUpdateIn) + TimeUtils.formatDuration(duration, TimeUnit.SECOND, showMilliSeconds = true) } val list = mutableListOf<String>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt index 2f7e09184..c0b282e18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.damageindicator -enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName: String = fullName) { +enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName: String = fullName, val showDeathTime: Boolean = false) { GENERIC_DUNGEON_BOSS("Generic Dungeon boss", 0),//TODO split into different bosses //Nether Mini Bosses @@ -15,31 +15,31 @@ enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName END_ENDSTONE_PROTECTOR("§cEndstone Protector", 3), END_ENDER_DRAGON("Ender Dragon", 4),//TODO fix totally - SLAYER_ZOMBIE_1("§aRevenant Horror 1", 5, "§aRev 1"), - SLAYER_ZOMBIE_2("§eRevenant Horror 2", 5, "§eRev 2"), - SLAYER_ZOMBIE_3("§cRevenant Horror 3", 5, "§cRev 3"), - SLAYER_ZOMBIE_4("§4Revenant Horror 4", 5, "§4Rev 4"), - SLAYER_ZOMBIE_5("§5Revenant Horror 5", 5, "§5Rev 5"), - - SLAYER_SPIDER_1("§aTarantula Broodfather 1", 6, "§aTara 1"), - SLAYER_SPIDER_2("§eTarantula Broodfather 2", 6, "§eTara 2"), - SLAYER_SPIDER_3("§cTarantula Broodfather 3", 6, "§cTara 3"), - SLAYER_SPIDER_4("§4Tarantula Broodfather 4", 6, "§4Tara 4"), - - SLAYER_WOLF_1("§aSven Packmaster 1", 7, "§aSven 1"), - SLAYER_WOLF_2("§eSven Packmaster 2", 7, "§eSven 2"), - SLAYER_WOLF_3("§cSven Packmaster 3", 7, "§cSven 3"), - SLAYER_WOLF_4("§4Sven Packmaster 4", 7, "§4Sven 4"), - - SLAYER_ENDERMAN_1("§aVoidgloom Seraph 1", 8, "§aVoid 1"), - SLAYER_ENDERMAN_2("§eVoidgloom Seraph 2", 8, "§eVoid 2"), - SLAYER_ENDERMAN_3("§cVoidgloom Seraph 3", 8, "§cVoid 3"), - SLAYER_ENDERMAN_4("§4Voidgloom Seraph 4", 8, "§4Void 4"), - - SLAYER_BLAZE_1("§aInferno Demonlord 1", 9, "§aInferno 1"), - SLAYER_BLAZE_2("§aInferno Demonlord 2", 9, "§aInferno 2"), - SLAYER_BLAZE_3("§aInferno Demonlord 3", 9, "§aInferno 3"), - SLAYER_BLAZE_4("§aInferno Demonlord 4", 9, "§aInferno 4"), + SLAYER_ZOMBIE_1("§aRevenant Horror 1", 5, "§aRev 1", showDeathTime = true), + SLAYER_ZOMBIE_2("§eRevenant Horror 2", 5, "§eRev 2", showDeathTime = true), + SLAYER_ZOMBIE_3("§cRevenant Horror 3", 5, "§cRev 3", showDeathTime = true), + SLAYER_ZOMBIE_4("§4Revenant Horror 4", 5, "§4Rev 4", showDeathTime = true), + SLAYER_ZOMBIE_5("§5Revenant Horror 5", 5, "§5Rev 5", showDeathTime = true), + + SLAYER_SPIDER_1("§aTarantula Broodfather 1", 6, "§aTara 1", showDeathTime = true), + SLAYER_SPIDER_2("§eTarantula Broodfather 2", 6, "§eTara 2", showDeathTime = true), + SLAYER_SPIDER_3("§cTarantula Broodfather 3", 6, "§cTara 3", showDeathTime = true), + SLAYER_SPIDER_4("§4Tarantula Broodfather 4", 6, "§4Tara 4", showDeathTime = true), + + SLAYER_WOLF_1("§aSven Packmaster 1", 7, "§aSven 1", showDeathTime = true), + SLAYER_WOLF_2("§eSven Packmaster 2", 7, "§eSven 2", showDeathTime = true), + SLAYER_WOLF_3("§cSven Packmaster 3", 7, "§cSven 3", showDeathTime = true), + SLAYER_WOLF_4("§4Sven Packmaster 4", 7, "§4Sven 4", showDeathTime = true), + + SLAYER_ENDERMAN_1("§aVoidgloom Seraph 1", 8, "§aVoid 1", showDeathTime = true), + SLAYER_ENDERMAN_2("§eVoidgloom Seraph 2", 8, "§eVoid 2", showDeathTime = true), + SLAYER_ENDERMAN_3("§cVoidgloom Seraph 3", 8, "§cVoid 3", showDeathTime = true), + SLAYER_ENDERMAN_4("§4Voidgloom Seraph 4", 8, "§4Void 4", showDeathTime = true), + + SLAYER_BLAZE_1("§aInferno Demonlord 1", 9, "§aInferno 1", showDeathTime = true), + SLAYER_BLAZE_2("§aInferno Demonlord 2", 9, "§aInferno 2", showDeathTime = true), + SLAYER_BLAZE_3("§aInferno Demonlord 3", 9, "§aInferno 3", showDeathTime = true), + SLAYER_BLAZE_4("§aInferno Demonlord 4", 9, "§aInferno 4", showDeathTime = true), SLAYER_BLAZE_TYPHOEUS_1("§aInferno Typhoeus 1", 9, "§aTyphoeus 1"), SLAYER_BLAZE_TYPHOEUS_2("§eInferno Typhoeus 2", 9, "§eTyphoeus 2"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 7390393d9..44c2e47ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -32,7 +32,6 @@ import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.text.DecimalFormat import java.util.* import java.util.regex.Pattern import kotlin.math.max @@ -40,7 +39,6 @@ import kotlin.math.max class DamageIndicatorManager { private var mobFinder: MobFinder? = null - private val decimalFormat = DecimalFormat("0.0") private val maxHealth = mutableMapOf<UUID, Long>() companion object { @@ -294,8 +292,8 @@ class DamageIndicatorManager { else -> LorenzColor.WHITE } - val d = (delay * 1.0) / 1000 - return color.getChatColor() + decimalFormat.format(d) + val format = TimeUtils.formatDuration(delay, showMilliSeconds = true) + return color.getChatColor() + format } @SubscribeEvent @@ -331,6 +329,9 @@ class DamageIndicatorManager { entityData.nameAbove = "" val customHealthText = if (health == 0L) { entityData.dead = true + if (entityData.bossType.showDeathTime && SkyHanniMod.feature.damageIndicator.timeToKillSlayer) { + entityData.nameAbove = entityData.timeToKill + } "§cDead" } else { getCustomHealth(entityData, health, entity, maxHealth) ?: return @@ -714,7 +715,8 @@ class DamageIndicatorManager { entityResult.ignoreBlocks, entityResult.delayedStart, entityResult.finalDungeonBoss, - entityResult.bossType + entityResult.bossType, + foundTime = System.currentTimeMillis() ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt index 2c7acc54b..7055b7df4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.damageindicator import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.entity.EntityLivingBase class EntityData( @@ -10,6 +12,7 @@ class EntityData( val finalDungeonBoss: Boolean, val bossType: BossType, val damageCounter: DamageCounter = DamageCounter(), + val foundTime: Long, var lastHealth: Long = 0L, var healthText: String = "", @@ -19,4 +22,9 @@ class EntityData( var nameAbove: String = "", var dead: Boolean = false, var deathLocation: LorenzVec? = null, -)
\ No newline at end of file +) { + val timeToKill by lazy { + val duration = System.currentTimeMillis() - foundTime + "§e" + TimeUtils.formatDuration(duration, TimeUnit.SECOND, showMilliSeconds = true) + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index baa5898c8..0487dfa2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -2,12 +2,9 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.utils.LocationUtils -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils.playSound -import at.hannibal2.skyhanni.utils.StringUtils import net.minecraft.client.Minecraft import net.minecraft.client.audio.ISound import net.minecraft.client.audio.PositionedSound @@ -101,7 +98,7 @@ class BarnFishingTimer { val duration = System.currentTimeMillis() - startTime val barnTimerAlertTime = SkyHanniMod.feature.fishing.barnTimerAlertTime * 1_000 val color = if (duration > barnTimerAlertTime) "§c" else "§e" - val timeFormat = StringUtils.formatDuration(duration / 1000, decimalFormat = true) + val timeFormat = TimeUtils.formatDuration(duration, biggestUnit = TimeUnit.MINUTE) val name = if (currentCount == 1) "sea creature" else "sea creatures" val text = "$color$timeFormat §8(§e$currentCount §b$name§8)" diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index cbf3f7fd1..30849e01d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -235,7 +235,7 @@ class MinionFeatures { if (SkyHanniMod.feature.minions.emptiedTimeDisplay) { if (lastEmptied != 0L) { val duration = System.currentTimeMillis() - lastEmptied - val format = StringUtils.formatDuration(duration / 1000) + " ago" + val format = TimeUtils.formatDuration(duration, longName = true) + " ago" val text = "§eHopper Emptied: $format" event.drawString(location.add(0.0, 1.15, 0.0), text, true) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 65b7992d6..7d118c1c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -9,7 +9,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings -import at.hannibal2.skyhanni.utils.StringUtils +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.network.play.server.S30PacketWindowItems import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter import net.minecraftforge.client.event.RenderGameOverlayEvent @@ -81,8 +82,8 @@ class NonGodPotEffectDisplay { if (label.contains("Fumes")) continue val until = effect.value - val seconds = (until - now) / 1000 - val format = StringUtils.formatDuration(seconds) + val seconds = until - now + val format = TimeUtils.formatDuration(seconds, TimeUnit.HOUR) val color = colorForTime(seconds) @@ -213,8 +214,8 @@ class NonGodPotEffectDisplay { if (label.contains("Invisibility")) { activeEffects[label] = System.currentTimeMillis() + 1000 * 60 * 60 * 24 } else { - activeEffects[label] = newValue - } + activeEffects[label] = newValue + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt index 163563981..09f125dbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt @@ -4,12 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth -import at.hannibal2.skyhanni.utils.LocationUtils -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.round -import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraft.entity.EntityLiving import net.minecraft.entity.monster.EntityBlaze @@ -70,8 +66,8 @@ class AreaMiniBossFeatures { private fun AreaMiniBossType.getTime(): String { val duration = System.currentTimeMillis() - lastTime val estimatedTime = respawnCooldown - duration % respawnCooldown - val double = (estimatedTime.toDouble() / 1000).round(1) - return color.getChatColor() + "" + LorenzUtils.formatDouble(double, "0.0") + "s" + val format = TimeUtils.formatDuration(estimatedTime, showMilliSeconds = true) + return color.getChatColor() + format } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt index 6fb7be0ff..2bafd6507 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt @@ -7,9 +7,9 @@ import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchRegex +import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.text.DecimalFormat class AshfangFreezeCooldown { @@ -34,9 +34,8 @@ class AshfangFreezeCooldown { val remainingLong = maxDuration - duration if (remainingLong > 0) { - val remaining = (remainingLong.toFloat() / 1000) - val format = DecimalFormat("0.0").format(remaining + 0.1) - SkyHanniMod.feature.ashfang.freezeCooldownPos.renderString("§cAshfang Freeze: §a${format}s") + var format = TimeUtils.formatDuration(remainingLong, showMilliSeconds = true) + SkyHanniMod.feature.ashfang.freezeCooldownPos.renderString("§cAshfang Freeze: §a$format") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt index 5fe8c7d8a..011c716df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -5,13 +5,14 @@ import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent -import java.text.DecimalFormat class AshfangNextResetCooldown { @@ -37,9 +38,8 @@ class AshfangNextResetCooldown { val remainingTime = spawnTime + 46_100 - System.currentTimeMillis() if (remainingTime > 0) { - val remaining = (remainingTime.toFloat() / 1000) - val format = DecimalFormat("0.0").format(remaining + 0.1) - SkyHanniMod.feature.ashfang.nextResetCooldownPos.renderString("§cAshfang next reset in: §a${format}s") + val format = TimeUtils.formatDuration(remainingTime, TimeUnit.SECOND, showMilliSeconds = true) + SkyHanniMod.feature.ashfang.nextResetCooldownPos.renderString("§cAshfang next reset in: §a$format") } else { spawnTime = -1 } |