From 82c777a54ad9996474c8120345f4b38f940ef2a7 Mon Sep 17 00:00:00 2001 From: martimavocado Date: Mon, 25 Nov 2024 02:08:26 +0000 Subject: [PATCH] Revert "code cleanup" This reverts commit 8da7ee195ab6fd8d9b46a06aee5f1fe3fa97ed8e. --- .../features/dungeon/DungeonLividFinder.kt | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index a13756f708f2..d4cbfeeb436e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -33,6 +33,7 @@ import at.hannibal2.skyhanni.utils.compat.EffectsCompat.Companion.activePotionEf import net.minecraft.block.BlockStainedGlass import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -48,6 +49,9 @@ object DungeonLividFinder { private set private var lividArmorStandId: Int? = null + val lividEntityOrArmorstand: Entity? + get() = livid?.baseEntity ?: lividArmorStandId?.let { EntityUtils.getEntityByID(it) } + private var fakeLivids = mutableSetOf() private var color: LorenzColor? = null @@ -59,18 +63,23 @@ object DungeonLividFinder { if (mob.name != "Livid" && mob.name != "Real Livid") return if (mob.baseEntity !is EntityOtherPlayerMP) return - val lividColor = color ?: run { + val lividColor = color + val isCorrectLivid = if (lividColor == null) false else mob.isLividColor(lividColor) + + if (lividColor == null) { fakeLivids += mob return } - livid = mob - lividArmorStandId = mob.armorStand?.entityId - // When the real livid dies at the same time as a fake livid, Hypixel despawns the player entity, - // and makes it impossible to get the mob of the real livid again. + if (isCorrectLivid) { + livid = mob + lividArmorStandId = mob.armorStand?.entityId + // When the real livid dies at the same time as a fake livid, Hypixel despawns the player entity, + // and makes it impossible to get the mob of the real livid again. - ChatUtils.debug("Livid found: $lividColor§7 | $lividArmorStandId") - if (config.enabled) mob.highlight(lividColor.toColor()) + ChatUtils.debug("Livid found: $lividColor§7 | $lividArmorStandId") + if (config.enabled) mob.highlight(lividColor.toColor()) + } else fakeLivids += mob } @SubscribeEvent @@ -155,7 +164,7 @@ object DungeonLividFinder { if (!inLividBossRoom() || !config.enabled) return if (isBlind) return - val entity = getLividEntityOrArmorStand() ?: return + val entity = lividEntityOrArmorstand ?: return val lorenzColor = color ?: return val location = event.exactLocation(entity) @@ -171,13 +180,11 @@ object DungeonLividFinder { } } - private fun getLividEntityOrArmorStand() = livid?.baseEntity ?: lividArmorStandId?.let { EntityUtils.getEntityByID(it) } - private fun inLividBossRoom() = DungeonAPI.inBossRoom && DungeonAPI.getCurrentBoss() == DungeonFloor.F5 @SubscribeEvent fun onDebug(event: DebugDataCollectEvent) { - event.title("Dungeon Livid Finder") + event.title("Livid Finder") if (!inLividBossRoom()) { event.addIrrelevant { @@ -189,7 +196,7 @@ object DungeonLividFinder { } event.addData { - add("In Livid Boss") + add("inBoss: ${inLividBossRoom()}") add("isBlind: $isBlind") add("blockColor: ${blockLocation.getBlockStateAt()}") add("livid: '${livid?.armorStand?.name}'")