diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 11:48:30 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 11:48:30 +0200 |
commit | 865331125f357ad60031d61cc8ec3f45bdc75df6 (patch) | |
tree | a8b6f74f2203204d104c53945844054d7f816b96 | |
parent | 72de6547ff9e3259a987b5285bd5fde410177ad0 (diff) | |
download | skyhanni-865331125f357ad60031d61cc8ec3f45bdc75df6.tar.gz skyhanni-865331125f357ad60031d61cc8ec3f45bdc75df6.tar.bz2 skyhanni-865331125f357ad60031d61cc8ec3f45bdc75df6.zip |
Add vampire slayer damage indicator features
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java | 29 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt | 67 |
2 files changed, 81 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java index 38c1e198c..e584e61df 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java @@ -1,10 +1,7 @@ package at.hannibal2.skyhanni.config.features; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; -import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.*; import java.util.ArrayList; import java.util.Arrays; @@ -89,4 +86,28 @@ public class DamageIndicatorConfig { @ConfigOption(name = "Time to Kill", desc = "Show the time it takes to kill the slayer boss.") @ConfigEditorBoolean public boolean timeToKillSlayer = true; + + + + @Expose + @ConfigOption(name = "Vampire Slayer", desc = "") + @Accordion + public VampireSlayerConfig vampireSlayer = new VampireSlayerConfig(); + + public static class VampireSlayerConfig { + @Expose + @ConfigOption(name = "HP untill Steak", desc = "Show the amount of HP miss1ing untill the steak can be used on the vampire slayer on top of the boss.") + @ConfigEditorBoolean + public boolean hpTillSteak = false; + + @Expose + @ConfigOption(name = "Mania Circles", desc = "Show a timer until the boss leaves the invicible Mania Circles state.") + @ConfigEditorBoolean + public boolean maniaCircles = false; + + @Expose + @ConfigOption(name = "Percentage HP", desc = "Show the percentage of HP next to the HP.") + @ConfigEditorBoolean + public boolean percentage = false; + } } 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 a869e28fc..6e0f0080d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -12,9 +12,12 @@ import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.between +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLivingBase @@ -376,9 +379,13 @@ class DamageIndicatorManager { BossType.SLAYER_ENDERMAN_2, BossType.SLAYER_ENDERMAN_3, BossType.SLAYER_ENDERMAN_4, - -> { - return checkEnderSlayer(entity as EntityEnderman, entityData, health.toInt(), maxHealth.toInt()) - } + -> return checkEnderSlayer(entity as EntityEnderman, entityData, health.toInt(), maxHealth.toInt()) + + BossType.SLAYER_BLOODFIEND_1, + BossType.SLAYER_BLOODFIEND_2, + BossType.SLAYER_BLOODFIEND_3, + BossType.SLAYER_BLOODFIEND_4, + -> return checkVampireSlayer(entity as EntityOtherPlayerMP, entityData, health.toInt(), maxHealth.toInt()) BossType.SLAYER_BLAZE_1, BossType.SLAYER_BLAZE_2, @@ -390,13 +397,14 @@ class DamageIndicatorManager { BossType.SLAYER_BLAZE_TYPHOEUS_2, BossType.SLAYER_BLAZE_TYPHOEUS_3, BossType.SLAYER_BLAZE_TYPHOEUS_4, - -> { - return checkBlazeSlayer(entity as EntityLiving, entityData, health.toInt(), maxHealth.toInt()) - } + -> return checkBlazeSlayer(entity as EntityLiving, entityData, health.toInt(), maxHealth.toInt()) - BossType.NETHER_MAGMA_BOSS -> { - return checkMagmaCube(entity as EntityMagmaCube, entityData, health.toInt(), maxHealth.toInt()) - } + BossType.NETHER_MAGMA_BOSS -> return checkMagmaCube( + entity as EntityMagmaCube, + entityData, + health.toInt(), + maxHealth.toInt() + ) BossType.SLAYER_ZOMBIE_5 -> { if ((entity as EntityZombie).hasNameTagWith(3, "§fBoom!")) { @@ -549,7 +557,6 @@ class DamageIndicatorManager { health: Int, maxHealth: Int, ): String? { - var calcHealth = health val calcMaxHealth: Int entityData.namePrefix = when (entityData.bossType) { @@ -622,7 +629,7 @@ class DamageIndicatorManager { // TODO replace this super ugly workaround with regex val text = name.between("Seraph ", " Hit") val hits = try { - text.toInt() + text.toInt() } catch (e: NumberFormatException) { text.substring(2).toInt() } @@ -647,6 +654,44 @@ class DamageIndicatorManager { return result } + private fun checkVampireSlayer( + entity: EntityOtherPlayerMP, + entityData: EntityData, + health: Int, + maxHealth: Int, + ): String? { + val config = SkyHanniMod.feature.damageIndicator.vampireSlayer + + if (config.percentage) { + val percentage = LorenzUtils.formatPercentage(health.toDouble() / maxHealth) + entityData.nameSuffix = " §e$percentage" + } + + if (config.maniaCircles) { + entity.ridingEntity?.let { + val existed = it.ticksExisted + if (existed > 40) { + val end = (20 * 26) - existed + val time = end.toDouble() / 20 + entityData.nameAbove = "Mania Circles: §b${time.round(1)}s" + return "" + } + } + } + + if (config.hpTillSteak) { + val rest = maxHealth * 0.2 + val showHealth = health - rest + if (showHealth < 300) { + entityData.nameAbove = if (showHealth > 0) { + "§cHP till Steak: ${showHealth.addSeparators()}" + } else "§cSteak!" + } + } + + return "" + } + private fun checkThorn(realHealth: Long, realMaxHealth: Long): String? { val maxHealth: Int println(" ") |