diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-09-04 22:38:28 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-09-04 22:38:28 +0200 |
commit | a4db6ba2104c7e59364c75e06edd5fd291b72406 (patch) | |
tree | dc2b66f596e074f3dac357ec27d9d05eb261aadf /src/main/java/at/hannibal2/skyhanni/features | |
parent | 22f7ac624784bc70721022699bc430bcca2f6357 (diff) | |
download | skyhanni-a4db6ba2104c7e59364c75e06edd5fd291b72406.tar.gz skyhanni-a4db6ba2104c7e59364c75e06edd5fd291b72406.tar.bz2 skyhanni-a4db6ba2104c7e59364c75e06edd5fd291b72406.zip |
added option to hide damage splashes around ashfang
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
3 files changed, 65 insertions, 25 deletions
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 de53ecfb2..3f9c88dac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -40,7 +40,16 @@ class DamageIndicatorManager { companion object { private var data = mutableMapOf<UUID, EntityData>() - val damagePattern: Pattern = Pattern.compile("✧?(\\d+[⚔+✧❤♞☄✷ﬗ]*)") + private val damagePattern: Pattern = Pattern.compile("✧?(\\d+[⚔+✧❤♞☄✷ﬗ]*)") + + fun isDamageSplash(entity: EntityLivingBase): Boolean { + if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false + if (!entity.hasCustomName()) return false + if (entity.isDead) return false + val name = entity.customNameTag.removeColor().replace(",", "") + + return damagePattern.matcher(name).matches() + } fun isBossSpawned(type: BossType): Boolean { return data.entries.find { it.value.bossType == type } != null @@ -176,8 +185,10 @@ class DamageIndicatorManager { } if (now > damageCounter.firstTick + 1_000) { - damageCounter.oldDamages.add(0, - OldDamage(now, damageCounter.currentDamage, damageCounter.currentHealing)) + damageCounter.oldDamages.add( + 0, + OldDamage(now, damageCounter.currentDamage, damageCounter.currentHealing) + ) damageCounter.firstTick = 0L damageCounter.currentDamage = 0 damageCounter.currentHealing = 0 @@ -389,6 +400,7 @@ class DamageIndicatorManager { "§a3/3 " } } + BossType.SLAYER_ENDERMAN_4 -> { val step = maxHealth / 6 calcMaxHealth = step @@ -412,6 +424,7 @@ class DamageIndicatorManager { "§a6/6 " } } + else -> return null } val result = @@ -461,10 +474,15 @@ class DamageIndicatorManager { 66_000, 132_000 -> 1 0 -> 0 else -> { - LorenzUtils.error("Unexpected health of thorn in f4! (${ - LorenzUtils.formatDouble(LorenzUtils.formatDouble( - realHealth.toDouble()).toDouble()) - })") + LorenzUtils.error( + "Unexpected health of thorn in f4! (${ + LorenzUtils.formatDouble( + LorenzUtils.formatDouble( + realHealth.toDouble() + ).toDouble() + ) + })" + ) return null } } @@ -481,10 +499,15 @@ class DamageIndicatorManager { 0 -> 0 else -> { LorenzTest.text = "thorn has ${LorenzUtils.formatDouble(realHealth.toDouble())} hp!" - LorenzUtils.error("Unexpected health of thorn in m4! (${ - LorenzUtils.formatDouble(LorenzUtils.formatDouble( - realHealth.toDouble()).toDouble()) - })") + LorenzUtils.error( + "Unexpected health of thorn in m4! (${ + LorenzUtils.formatDouble( + LorenzUtils.formatDouble( + realHealth.toDouble() + ).toDouble() + ) + })" + ) return null } } @@ -551,11 +574,8 @@ class DamageIndicatorManager { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { val entity = event.entity - if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return - if (!entity.hasCustomName()) return - if (entity.isDead) return + if (!isDamageSplash(entity)) return val name = entity.customNameTag.removeColor().replace(",", "") - if (!damagePattern.matcher(name).matches()) return if (SkyHanniMod.feature.misc.fixSkytilsDamageSplash) { entity.customNameTag = entity.customNameTag.replace(",", "") diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt index 397038401..62d28d3cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -2,9 +2,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.entity.EntityLivingBase -import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -16,13 +14,8 @@ class DungeonBossHideDamageSplash { if (!SkyHanniMod.feature.dungeon.damageSplashBoss) return if (!DungeonData.inBossRoom) return - val entity = event.entity - if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return - if (!entity.hasCustomName()) return - if (entity.isDead) return - val name = entity.customNameTag.removeColor().replace(",", "") - if (!DamageIndicatorManager.damagePattern.matcher(name).matches()) return - - event.isCanceled = true + if (DamageIndicatorManager.isDamageSplash(event.entity)) { + event.isCanceled = true + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt new file mode 100644 index 000000000..3785a3f76 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt @@ -0,0 +1,27 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.features.damageindicator.BossType +import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.EntityLivingBase +import net.minecraftforge.client.event.RenderLivingEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class AshfangHideDamageIndicator { + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + if (!isEnabled()) return + + if (DamageIndicatorManager.isDamageSplash(event.entity)) { + event.isCanceled = true + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.hideDamageSplash && + DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) + } +}
\ No newline at end of file |