From a4db6ba2104c7e59364c75e06edd5fd291b72406 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Sun, 4 Sep 2022 22:38:28 +0200 Subject: added option to hide damage splashes around ashfang --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../skyhanni/config/features/Ashfang.java | 5 +++ .../damageindicator/DamageIndicatorManager.kt | 50 +++++++++++++++------- .../dungeon/DungeonBossHideDamageSplash.kt | 13 ++---- .../nether/ashfang/AshfangHideDamageIndicator.kt | 27 ++++++++++++ 5 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index fdcefcea9..e7ca8c882 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -90,6 +90,7 @@ public class SkyHanniMod { registerEvent(new AshfangBlazingSouls()); registerEvent(new AshfangBlazes()); registerEvent(new AshfangHideParticles()); + registerEvent(new AshfangHideDamageIndicator()); registerEvent(new ItemStars()); registerEvent(new MinionFeatures()); registerEvent(new RealTime()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java b/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java index 92d3b3bf4..909649633 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java @@ -69,4 +69,9 @@ public class Ashfang { @ConfigOption(name = "Ashfang Hide Names", desc = "Hide the name of full health blazes around ashfang (only useful when highlight blazes is enabled)") @ConfigEditorBoolean public boolean hideNames = false; + + @Expose + @ConfigOption(name = "Ashfang Hide Damage", desc = "Hide damage splashes around ashfang") + @ConfigEditorBoolean + public boolean hideDamageSplash = 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 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() - 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) { 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) { + 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 -- cgit