Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: livid finder but again #3511

Draft
wants to merge 3 commits into
base: beta
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.mob.Mob
import at.hannibal2.skyhanni.data.mob.MobData
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.chat.SkyHanniChatEvent
import at.hannibal2.skyhanni.events.dungeon.DungeonBossRoomEnterEvent
import at.hannibal2.skyhanni.events.dungeon.DungeonCompleteEvent
import at.hannibal2.skyhanni.events.minecraft.SkyHanniRenderWorldEvent
Expand All @@ -22,9 +24,11 @@
import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.MobUtils.mob
import at.hannibal2.skyhanni.utils.RecalculatingValue
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBoxNea
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
Expand All @@ -33,11 +37,13 @@
import at.hannibal2.skyhanni.utils.TimeUtils.ticks
import at.hannibal2.skyhanni.utils.compat.EffectsCompat
import at.hannibal2.skyhanni.utils.compat.EffectsCompat.Companion.activePotionEffect
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
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.minecraft.item.EnumDyeColor

@SkyHanniModule
object DungeonLividFinder {
Expand All @@ -57,6 +63,13 @@

private var color: LorenzColor? = null

private val lividKillPattern by RepoPattern.pattern(

Check warning on line 66 in src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.RepoRules.RepoPatternRegexTestMissing

Repo pattern `lividKillPattern` must have a regex test.
"dungeon.f5.lividkill",
"§c\\[BOSS](?:[\\w ]+)? Livid§r§f: Impossible! How did you figure out which one I was\\?!"
)

private val logger = LorenzLogger("livid_finder")

@HandleEvent
fun onMobSpawn(event: MobEvent.Spawn.SkyblockMob) {
if (!inLividBossRoom()) return
Expand All @@ -65,7 +78,7 @@
if (mob.baseEntity !is EntityOtherPlayerMP) return

val lividColor = color
val isCorrectLivid = if (lividColor == null) false else mob.isLividColor(lividColor)
val isCorrectLivid = lividColor != null && mob.isLividColor(lividColor)

if (lividColor == null) {
fakeLivids += mob
Expand All @@ -78,7 +91,10 @@
// 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")
val message = "Livid found: $lividColor§7 | $lividArmorStandId (direct spawn)"
logger.log(message)
ChatUtils.debug(message)

if (config.enabled.get()) mob.highlight(lividColor.toColor())
} else fakeLivids += mob
}
Expand Down Expand Up @@ -106,47 +122,56 @@
if (event.location != blockLocation) return
if (event.location.getBlockAt() != Blocks.wool) return

val newColor = event.newState.getValue(BlockStainedGlass.COLOR).toLorenzColor()
val newColor = event.newState.getValue(BlockStainedGlass.COLOR).getColor() ?: run {
val message = "bad color found! ${event.newState.getValue(BlockStainedGlass.COLOR)}"
ChatUtils.userError(message)
logger.log(message)
event.newState.getValue(BlockStainedGlass.COLOR).toLorenzColor()
}
color = newColor
ChatUtils.debug("newColor! $newColor")

val lividSet = fakeLivids + livid

for (mob in lividSet) {
if (mob == null) continue
if (mob.isLividColor(LorenzColor.RED) && newColor != LorenzColor.RED) {
if (mob == livid) {
livid = null
lividArmorStandId = null
}
mob.highlight(null)
fakeLivids += mob
continue
}

val colorMessage = "newColor! $newColor"
ChatUtils.debug(colorMessage)
logger.log(colorMessage)

fakeLivids.clear()
livid = null
lividArmorStandId = null

for (mob in MobData.currentMobs) {
if (mob.name != "Livid" && mob.name != "Real Livid") continue

mob.highlight(null)
if (mob.isLividColor(newColor)) {
livid = mob
lividArmorStandId = mob.armorStand?.entityId
ChatUtils.debug("Livid found: $newColor§7 | $lividArmorStandId")

val message = "Livid found: $newColor§7 | $lividArmorStandId (color switch)"
ChatUtils.debug(message)
logger.log(message)

if (config.enabled.get()) mob.highlight(newColor.toColor())
fakeLivids -= mob
continue
}

fakeLivids.add(mob)
}
}

var bossCount = 1

@HandleEvent
fun onBossStart(event: DungeonBossRoomEnterEvent) {
if (DungeonApi.getCurrentBoss() != DungeonFloor.F5) return
color = LorenzColor.RED
logger.log("-----")
logger.log("start boss $bossCount\n")
bossCount += 1
}

@HandleEvent
fun onBossEnd(event: DungeonCompleteEvent) {
color = null
livid = null
lividArmorStandId = null
fakeLivids.clear()
reset()
}

@HandleEvent
Expand Down Expand Up @@ -222,5 +247,73 @@
add("lividArmorStandID: $lividArmorStandId")
add("color: ${color?.name}")
}

fakeLivids.clear()
livid = null
lividArmorStandId = null
val color = color ?: return
logger.log("reloading livids")

for (mob in MobData.currentMobs) {
if (mob.name != "Livid" && mob.name != "Real Livid") continue

mob.highlight(null)
if (mob.isLividColor(color)) {
livid = mob
lividArmorStandId = mob.armorStand?.entityId

val message = "Livid found: ${color}§7 | $lividArmorStandId (color switch)"

Check warning on line 265 in src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.formatting.StringTemplate

Redundant curly braces
ChatUtils.debug(message)
logger.log(message)

if (config.enabled.get()) mob.highlight(color.toColor())
continue
}

fakeLivids.add(mob)
}
ChatUtils.chat("reloaded livids!")
}

@HandleEvent
fun onChat(event: SkyHanniChatEvent) {
if (!inLividBossRoom()) return
if (!lividKillPattern.matches(event.message)) return

reset()
}

private fun reset() {
color = null
livid = null
lividArmorStandId = null
fakeLivids.clear()
}

private fun EnumDyeColor.getColor(): LorenzColor? =
when (this) {
EnumDyeColor.WHITE -> LorenzColor.WHITE

EnumDyeColor.GRAY -> LorenzColor.GRAY

EnumDyeColor.MAGENTA -> LorenzColor.LIGHT_PURPLE
EnumDyeColor.PURPLE -> LorenzColor.DARK_PURPLE

EnumDyeColor.BLUE -> LorenzColor.BLUE
EnumDyeColor.RED -> LorenzColor.RED
EnumDyeColor.YELLOW -> LorenzColor.YELLOW

EnumDyeColor.LIME -> LorenzColor.GREEN
EnumDyeColor.GREEN -> LorenzColor.DARK_GREEN

else -> null
// these don't exist (for now?)
// EnumDyeColor.ORANGE
// EnumDyeColor.LIGHT_BLUE
// EnumDyeColor.PINK
// EnumDyeColor.SILVER
// EnumDyeColor.CYAN
// EnumDyeColor.BROWN
// EnumDyeColor.BLACK
}
}
Loading