diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-15 14:57:04 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-15 14:57:04 +0200 |
commit | 2b10ec4187769a5d7b29db52439fdb52971605de (patch) | |
tree | 2dde95d612ebc1c7e9e1cbca3c506fa01a23e692 /src | |
parent | 73fcbc6b6bfe9da5a8fd9ddb5c66d452c15e5cb0 (diff) | |
download | skyhanni-2b10ec4187769a5d7b29db52439fdb52971605de.tar.gz skyhanni-2b10ec4187769a5d7b29db52439fdb52971605de.tar.bz2 skyhanni-2b10ec4187769a5d7b29db52439fdb52971605de.zip |
added hits needed for eman slayer, added 4 separate slayer entities
Diffstat (limited to 'src')
4 files changed, 119 insertions, 100 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt index 3624f479b..0ad303929 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt @@ -7,6 +7,8 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.misc.ScoreboardData import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth +import at.hannibal2.skyhanni.utils.LorenzUtils.between +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.EntityLivingBase @@ -57,21 +59,20 @@ class BossDamageIndicator { if (!data.ignoreBlocks) { if (!player.canEntityBeSeen(data.entity)) continue } - if (data.hidden) continue + if (data.healthLineHidden) continue if (data.bossType.bossTypeToggle !in SkyHanniMod.feature.misc.damageIndicatorBossesToShow) continue val entity = data.entity - var color = data.color - var text = data.text + var healthText = data.healthText val delayedStart = data.delayedStart if (delayedStart != -1L) { if (delayedStart > System.currentTimeMillis()) { val delay = delayedStart - System.currentTimeMillis() - color = colorForTime(delay) + val color = colorForTime(delay) var d = delay * 1.0 d /= 1000 - text = decimalFormat.format(d) + healthText = color.getChatColor() + decimalFormat.format(d) } } @@ -83,7 +84,7 @@ class BossDamageIndicator { ) RenderUtils.drawLabel( pos, - color.getChatColor() + text, + healthText, partialTicks, true, 6f @@ -155,6 +156,8 @@ class BossDamageIndicator { var calcHealth = health var calcMaxHealth = maxHealth + entityData.namePrefix = "" + entityData.nameSuffix = "" if (DungeonData.isOneOf("F4")) { calcHealth = when (health) { @@ -183,79 +186,82 @@ class BossDamageIndicator { // calcMaxHealth = 4 } + var customHealthText = "" - if (entityData.bossType == BossType.END_ENDERMAN_SLAYER) { + if (entityData.bossType == BossType.SLAYER_ENDERMAN_1 || + entityData.bossType == BossType.SLAYER_ENDERMAN_2 || + entityData.bossType == BossType.SLAYER_ENDERMAN_3 || + entityData.bossType == BossType.SLAYER_ENDERMAN_4 + ) { var statePrefix = "" //Hides the damage indicator when in hit phase or in laser phase if (entity is EntityEnderman) { - var hidden = false - val hasNameTagWith = entity.hasNameTagWith(3, " Hit") -// println("is in hit phase: $hasNameTagWith") - if (hasNameTagWith) hidden = true - if (entity.ridingEntity != null) hidden = true - entityData.hidden = hidden - } - - if (!entityData.hidden) { - //custom prefix and health for the four different ender slayers - when (maxHealth) { - 300_000_000, 600_000_000 -> { - entityData.namePrefix = "§4" - entityData.nameSuffix = " 4" - val step = maxHealth / 6 - calcMaxHealth = step - if (health > step * 5) { - calcHealth -= step * 5 - statePrefix = "§c1/6 " - } else if (health > step * 4) { - calcHealth -= step * 4 - statePrefix = "§e2/6 " - } else if (health > step * 3) { - calcHealth -= step * 3 - statePrefix = "§e3/6 " - } else if (health > step * 2) { - calcHealth -= step * 2 - statePrefix = "§e4/6 " - } else if (health > step) { - calcHealth -= step - statePrefix = "§e5/6 " - } else { - calcHealth = health - statePrefix = "§a6/6 " - } + entity.hasNameTagWith(3, " Hit", consumer = { + val name = it.name.removeColor() + + val maxHits = when (entityData.bossType) { + BossType.SLAYER_ENDERMAN_1 -> 15 + BossType.SLAYER_ENDERMAN_2 -> 30 + BossType.SLAYER_ENDERMAN_3 -> 60 + BossType.SLAYER_ENDERMAN_4 -> 100 + else -> 100 } - else -> { - when (maxHealth) { - 300_000, 600_000 -> { - entityData.namePrefix = "§a" - entityData.nameSuffix = " 1" - } - 15_000_000, 30_000_000 -> { - entityData.namePrefix = "§e" - entityData.nameSuffix = " 2" - } - 66_666_666, 66_666_666 * 2 -> { - entityData.namePrefix = "§c" - entityData.nameSuffix = " 3" - } - } + val hits = name.between("Seraph ", " Hits").toInt() + val color = percentageColor(hits, maxHits) - val step = maxHealth / 3 + customHealthText = color.getChatColor() + "$hits Hits" + }) + if (entity.ridingEntity != null) { + entityData.healthLineHidden = true + } + } - calcMaxHealth = step - if (health > step * 2) { - calcHealth -= step * 2 - statePrefix = "§c1/3 " - } else if (health > step) { - calcHealth -= step - statePrefix = "§e2/3 " - } else { - calcHealth = health - statePrefix = "§a3/3 " - } + when (entityData.bossType) { + BossType.SLAYER_ENDERMAN_4 -> { + entityData.namePrefix = "§4" + entityData.nameSuffix = " 4" + val step = maxHealth / 6 + calcMaxHealth = step + if (health > step * 5) { + calcHealth -= step * 5 + statePrefix = "§c1/6 " + } else if (health > step * 4) { + calcHealth -= step * 4 + statePrefix = "§e2/6 " + } else if (health > step * 3) { + calcHealth -= step * 3 + statePrefix = "§e3/6 " + } else if (health > step * 2) { + calcHealth -= step * 2 + statePrefix = "§e4/6 " + } else if (health > step) { + calcHealth -= step + statePrefix = "§e5/6 " + } else { + calcHealth = health + statePrefix = "§a6/6 " + } + } + BossType.SLAYER_ENDERMAN_1, + BossType.SLAYER_ENDERMAN_2, + BossType.SLAYER_ENDERMAN_3, + -> { + val step = maxHealth / 3 + + calcMaxHealth = step + if (health > step * 2) { + calcHealth -= step * 2 + statePrefix = "§c1/3 " + } else if (health > step) { + calcHealth -= step + statePrefix = "§e2/3 " + } else { + calcHealth = health + statePrefix = "§a3/3 " } } + else -> {} } entityData.namePrefix = statePrefix + entityData.namePrefix } @@ -276,7 +282,7 @@ class BossDamageIndicator { //hide while in the middle val position = entity.getLorenzVec() - entityData.hidden = position.x == -368.0 && position.z == -804.0 + entityData.healthLineHidden = position.x == -368.0 && position.z == -804.0 for (line in ScoreboardData.sidebarLinesRaw) { if (line.contains("▎")) { @@ -302,15 +308,7 @@ class BossDamageIndicator { } } } - - val percentage = calcHealth.toDouble() / calcMaxHealth.toDouble() - val color = when { - percentage > 0.9 -> LorenzColor.DARK_GREEN - percentage > 0.75 -> LorenzColor.GREEN - percentage > 0.5 -> LorenzColor.YELLOW - percentage > 0.25 -> LorenzColor.GOLD - else -> LorenzColor.RED - } + val color = percentageColor(calcHealth, calcMaxHealth) if (SkyHanniMod.feature.misc.damageIndicatorHealingMessage) { if (data.containsKey(entity.uniqueID)) { @@ -321,8 +319,11 @@ class BossDamageIndicator { } entityData.lastHealth = health - entityData.text = NumberUtil.format(calcHealth) - entityData.color = color + if (customHealthText.isNotEmpty()) { + entityData.healthText = customHealthText + } else { + entityData.healthText = color.getChatColor() + NumberUtil.format(calcHealth) + } entityData.timeLastTick = System.currentTimeMillis() data[entity.uniqueID] = entityData @@ -331,6 +332,20 @@ class BossDamageIndicator { } } + private fun percentageColor( + have: Int, + max: Int, + ): LorenzColor { + val percentage = have.toDouble() / max.toDouble() + return when { + percentage > 0.9 -> LorenzColor.DARK_GREEN + percentage > 0.75 -> LorenzColor.GREEN + percentage > 0.5 -> LorenzColor.YELLOW + percentage > 0.25 -> LorenzColor.GOLD + else -> LorenzColor.RED + } + } + private fun checkHealed(health: Int, lastHealth: Int, bossType: BossType) { val healed = health - lastHealth if (healed <= 0) return diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt index ac9c95e8c..7239b501a 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt @@ -224,20 +224,21 @@ class BossFinder { if (entity is EntityEnderman) { if (entity.hasNameTagWith(3, "§c☠ §bVoidgloom Seraph ")) { - if (entity.baseMaxHealth == 300_000.0 || - entity.baseMaxHealth == 15_000_000.0 || - entity.baseMaxHealth == 66_666_666.0 || - entity.baseMaxHealth == 300_000_000.0 - ) { - return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER) - } - //Derpy - if (entity.baseMaxHealth == 600_000.0 || - entity.baseMaxHealth == 30_000_000.0 || - entity.baseMaxHealth == 66_666_666.0 * 2.0 || - entity.baseMaxHealth == 600_000_000.0 - ) { - return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER) + + + when (entity.baseMaxHealth.toInt()) { + 300_000, 600_000 -> { + return EntityResult(bossType = BossType.SLAYER_ENDERMAN_1) + } + 15_000_000, 30_000_000 -> { + return EntityResult(bossType = BossType.SLAYER_ENDERMAN_2) + } + 66_666_666, 66_666_666 * 2 -> { + return EntityResult(bossType = BossType.SLAYER_ENDERMAN_3) + } + 300_000_000, 600_000_000 -> { + return EntityResult(bossType = BossType.SLAYER_ENDERMAN_4) + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossType.kt index 3490bddbd..6a77ecd12 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossType.kt @@ -19,7 +19,12 @@ enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName HUB_REVENANT_HORROR("§5Revenant Horror 5", 5, "§5Rev 5"), SPIDER_SLAYER("Spider Slayer", 6, "Spider"), WOLF_SLAYER("Wolf Slayer", 7, "Wolf"), - END_ENDERMAN_SLAYER("Voidgloom Seraph", 8), + + SLAYER_ENDERMAN_1("§aVoidgloom Seraph 1", 8), + SLAYER_ENDERMAN_2("§eVoidgloom Seraph 2", 8), + SLAYER_ENDERMAN_3("§cVoidgloom Seraph 3", 8), + SLAYER_ENDERMAN_4("§4Voidgloom Seraph 4", 8), + BLAZE_SLAYER("Blaze Slayer", 9, "Blaze"), HUB_HEADLESS_HORSEMAN("§6Headless Horseman", 10), diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt index f7a56d620..0f85b8733 100644 --- a/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.damageindicator -import at.hannibal2.skyhanni.utils.LorenzColor import net.minecraft.entity.EntityLivingBase class EntityData( @@ -11,10 +10,9 @@ class EntityData( val bossType: BossType = BossType.DUNGEON, var lastHealth: Int = 0, - var text: String = "", - var color: LorenzColor = LorenzColor.DARK_GREEN, + var healthText: String = "", var timeLastTick: Long = 0, - var hidden: Boolean = false, + var healthLineHidden: Boolean = false, var namePrefix: String = "", var nameSuffix: String = "" )
\ No newline at end of file |