diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-24 17:21:32 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-24 17:21:32 +0200 |
commit | ea1a2980a6cb6b465c1f6911c959335aca25cb80 (patch) | |
tree | 37d9113c8523e8843b0ac71b6f311cdd75229ac4 /src/main/java/at/hannibal2/skyhanni | |
parent | 1ea9026acb04504200892b67c81c60ee64723b12 (diff) | |
download | skyhanni-ea1a2980a6cb6b465c1f6911c959335aca25cb80.tar.gz skyhanni-ea1a2980a6cb6b465c1f6911c959335aca25cb80.tar.bz2 skyhanni-ea1a2980a6cb6b465c1f6911c959335aca25cb80.zip |
hiding damage splashes while inside the boss room (fixing Skytils feature)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
12 files changed, 103 insertions, 43 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 48b568a9f..353cfa934 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -72,16 +72,17 @@ public class SkyHanniMod { registerEvent(new PlayerChatFilter()); registerEvent(new DungeonChatFilter()); registerEvent(new HideNotClickableItems()); - registerEvent(new DungeonHighlightClickedBlocks()); registerEvent(new ItemDisplayOverlayFeatures()); registerEvent(new CurrentPetDisplay()); registerEvent(new ExpBottleOnGroundHider()); registerEvent(new DamageIndicatorManager()); registerEvent(new ItemAbilityCooldown()); + registerEvent(new DungeonHighlightClickedBlocks()); registerEvent(new DungeonMilestonesDisplay()); registerEvent(new DungeonDeathCounter()); registerEvent(new DungeonCleanEnd()); registerEvent(new DungeonBossMessages()); + registerEvent(new DungeonBossHideDamageSplash()); registerEvent(new TrophyFishMessages()); registerEvent(new BazaarBestSellMethod()); registerEvent(new AnvilCombineHelper()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java b/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java index 74d2a076c..67b61d737 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Dungeon.java @@ -59,4 +59,9 @@ public class Dungeon { @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean cleanEndF3IgnoreGuardians = false; + + @Expose + @ConfigOption(name = "Boss Damage Splash", desc = "Hiding damage splashes while inside the boss room (fixing Skytils feature)") + @ConfigEditorBoolean + public boolean damageSplashBoss = false; }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 98370fee7..91e1240a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -2,12 +2,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.LocationChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListUtils import net.minecraft.client.Minecraft -import net.minecraft.network.play.server.S38PacketPlayerListItem import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -18,7 +16,6 @@ class HypixelData { companion object { var hypixel = false var skyblock = false - var dungeon = false var mode: String = "" } @@ -33,31 +30,14 @@ class HypixelData { val areaRegex = Regex("§r§b§l(?<area>[\\w]+): §r§7(?<loc>[\\w ]+)§r") @SubscribeEvent - fun onTabUpdate(event: PacketEvent.ReceiveEvent) { - if (dungeon || !hypixel || event.packet !is S38PacketPlayerListItem || - (event.packet.action != S38PacketPlayerListItem.Action.UPDATE_DISPLAY_NAME && - event.packet.action != S38PacketPlayerListItem.Action.ADD_PLAYER) - ) return - event.packet.entries.forEach { playerData -> - val name = playerData?.displayName?.formattedText ?: playerData?.profile?.name ?: return@forEach - areaRegex.matchEntire(name)?.let { result -> - dungeon = skyblock && result.groups["area"]?.value == "Dungeon" - return@forEach - } - } - } - - @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { skyblock = false - dungeon = false } @SubscribeEvent fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { hypixel = false skyblock = false - dungeon = false } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/events/DungeonEnterEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DungeonEnterEvent.kt deleted file mode 100644 index 819ae8c71..000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/DungeonEnterEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package at.hannibal2.skyhanni.events - -class DungeonEnterEvent(dungeonFloor: String): LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/DungeonStartEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DungeonStartEvent.kt new file mode 100644 index 000000000..788d2fda6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/DungeonStartEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.events + +class DungeonStartEvent(dungeonFloor: String): LorenzEvent()
\ No newline at end of file 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 8f397de02..5d7ddd3be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -36,7 +36,10 @@ class DamageIndicatorManager { private var mobFinder: MobFinder? = null private val decimalFormat = DecimalFormat("0.0") private val maxHealth = mutableMapOf<UUID, Int>() - private val damagePattern = Pattern.compile("✧?(\\d+[⚔+✧❤♞☄✷ﬗ]*)") + + companion object { + val damagePattern: Pattern = Pattern.compile("✧?(\\d+[⚔+✧❤♞☄✷ﬗ]*)") + } @SubscribeEvent fun onWorldLoad(event: WorldEvent.Load) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt new file mode 100644 index 000000000..397038401 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -0,0 +1,28 @@ +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 + +class DungeonBossHideDamageSplash { + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + 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 + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt index e8f569b4d..1ffd0fc70 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt @@ -10,11 +10,12 @@ class DungeonBossMessages { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.inSkyblock) return + if (!LorenzUtils.inDungeons) return + if (!isBoss(event.message)) return - if (!SkyHanniMod.feature.chat.dungeonBossMessages) return + DungeonData.handleBossMessage(event.message) - if (isBoss(event.message)) { + if (SkyHanniMod.feature.chat.dungeonBossMessages) { event.blockedReason = "dungeon_boss" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt index 1ae704653..93f8c659a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt @@ -1,8 +1,9 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.events.DungeonEnterEvent -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.events.DungeonStartEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -11,6 +12,10 @@ class DungeonData { companion object { var dungeonFloor: String? = null + var inBossRoom = false + var started = false + + fun inDungeon() = dungeonFloor != null fun isOneOf(vararg floors: String): Boolean { for (floor in floors) { @@ -21,19 +26,42 @@ class DungeonData { return false } + + fun handleBossMessage(rawMessage: String) { + if (!inDungeon()) return + val message = rawMessage.removeColor() + val bossName = message.substringAfter("[BOSS] ").substringBefore(":").trim() + if (bossName != "The Watcher" && dungeonFloor != null && checkBossName(dungeonFloor!!, bossName)) { + inBossRoom = true + } + } + + private fun checkBossName(floor: String, bossName: String): Boolean { + val correctBoss = when (floor) { + "E" -> "The Watcher" + "F1", "M1" -> "Bonzo" + "F2", "M2" -> "Scarf" + "F3", "M3" -> "The Professor" + "F4", "M4" -> "Thorn" + "F5", "M5" -> "Livid" + "F6", "M6" -> "Sadan" + "F7", "M7" -> "Maxor" + else -> null + } ?: return false + + // Livid has a prefix in front of the name, so we check ends with to cover all the livids + return bossName.endsWith(correctBoss) + } } @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return - if (LorenzUtils.inDungeons) { - if (dungeonFloor == null) { - for (line in ScoreboardData.sidebarLines) { - if (line.contains("The Catacombs (")) { - dungeonFloor = line.substringAfter("(").substringBefore(")") - DungeonEnterEvent(dungeonFloor!!).postAndCatch() - break - } + if (dungeonFloor == null) { + for (line in ScoreboardData.sidebarLines) { + if (line.contains("The Catacombs (")) { + dungeonFloor = line.substringAfter("(").substringBefore(")") + break } } } @@ -42,5 +70,18 @@ class DungeonData { @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { dungeonFloor = null + started = false + inBossRoom = false + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + val floor = dungeonFloor + if (floor != null) { + if (event.message == "§e[NPC] §bMort§f: §rHere, I found this map when I first entered the dungeon.") { + started = true + DungeonStartEvent(floor).postAndCatch() + } + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt index 129d9e3bd..d3091f944 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.DungeonEnterEvent +import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex @@ -73,7 +73,7 @@ class DungeonDeathCounter { } @SubscribeEvent - fun onDungeonStart(event: DungeonEnterEvent) { + fun onDungeonStart(event: DungeonStartEvent) { deaths = 0 update() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index 12af1c7a4..94367d329 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.DungeonEnterEvent +import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex @@ -78,7 +78,7 @@ class DungeonMilestonesDisplay { } @SubscribeEvent - fun onDungeonStart(event: DungeonEnterEvent) { + fun onDungeonStart(event: DungeonStartEvent) { currentMilestone = 0 update() } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 0bb869bac..322fc2b44 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.features.dungeon.DungeonData import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes @@ -18,7 +19,7 @@ object LorenzUtils { get() = isOnHypixel && HypixelData.skyblock val inDungeons: Boolean - get() = inSkyblock && HypixelData.dungeon + get() = inSkyblock && DungeonData.inDungeon() val skyBlockIsland: String get() = HypixelData.mode |