From d1a5af0688c6079da4b150615779d835d36dfd21 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 6 Apr 2024 00:15:07 +0200 Subject: Fix: M7 Mob Detection (#1367) --- .../java/at/hannibal2/skyhanni/data/mob/MobData.kt | 6 +++++ .../at/hannibal2/skyhanni/data/mob/MobFilter.kt | 26 +++++++++++++++++----- .../at/hannibal2/skyhanni/utils/CollectionUtils.kt | 8 +++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt index b8da58d41..acd8cad6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.utils.CollectionUtils.takeIfAllNotNull import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.EntityLivingBase @@ -56,6 +57,11 @@ class MobData { this?.let { armor -> mob.invoke(armor)?.let { found(it) } ?: somethingWentWrong } ?: notYetFound + + fun List.makeMobResult(mob: (List) -> Mob?) = + this.takeIfAllNotNull()?.let { armor -> + mob.invoke(armor)?.let { found(it) } ?: somethingWentWrong + } ?: notYetFound } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt index be67bb6c4..44b54a913 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt @@ -58,18 +58,19 @@ object MobFilter { private val repoGroup = RepoPattern.group("mob.detection") + /** REGEX-TEST: Wither Husk 500M❤ */ val mobNameFilter by repoGroup.pattern( "filter.basic", - "(?:\\[\\w+(?\\d+)\\] )?(?.Corrupted )?(?.*) [\\d❤]+" + "(?:\\[\\w+(?\\d+)\\] )?(?.Corrupted )?(?[^ᛤ]*)(?: ᛤ)? [\\dBMk.,❤]+" ) val slayerNameFilter by repoGroup.pattern("filter.slayer", "^. (?.*) (?[IV]+) \\d+.*") val bossMobNameFilter by repoGroup.pattern( "filter.boss", - "^. (?:\\[\\w+(?\\d+)\\] )?(?.*) (?:[\\d\\/Mk.,❤]+|█+) .$" + "^. (?:\\[\\w+(?\\d+)\\] )?(?[^ᛤ]*)(?: ᛤ)? (?:[\\d\\/BMk.,❤]+|█+) .$" ) val dungeonNameFilter by repoGroup.pattern( "filter.dungeon", - "^(?:(?✯)\\s)?(?:(?${DungeonAttribute.toRegexLine})\\s)?(?:\\[[\\w\\d]+\\]\\s)?(?.+)\\s[^\\s]+$" + "^(?:(?✯)\\s)?(?:(?${DungeonAttribute.toRegexLine})\\s)?(?:\\[[\\w\\d]+\\]\\s)?(?[^ᛤ]+)(?: ᛤ)?\\s[^\\s]+$" ) val summonFilter by repoGroup.pattern("filter.summon", "^(?\\w+)'s (?.*) \\d+.*") val dojoFilter by repoGroup.pattern("filter.dojo", "^(?:(?\\d+) pts|(?\\w+))$") @@ -82,7 +83,7 @@ object MobFilter { val wokeSleepingGolemPattern by repoGroup.pattern("pattern.dungeon.woke.golem", "(?:§c§lWoke|§5§lSleeping) Golem§r") val jerryMagmaCubePattern by repoGroup.pattern( "pattern.jerry.magma.cube", - "§c(?:Cubie|Maggie|Cubert|Cübe|Cubette|Magmalene|Lucky 7|8ball|Mega Cube|Super Cube) §a\\d+§8\\/§a\\d+§c❤" + "§c(?:Cubie|Maggie|Cubert|Cübe|Cubette|Magmalene|Lucky 7|8ball|Mega Cube|Super Cube)(?: ᛤ)? §a\\d+§8\\/§a\\d+§c❤" ) val summonOwnerPattern by repoGroup.pattern("pattern.summon.owner", ".*Spawned by: (?.*).*") @@ -209,7 +210,15 @@ object MobFilter { baseEntity is EntityBat -> createBat(baseEntity) baseEntity.isFarmMob() -> createFarmMobs(baseEntity)?.let { MobResult.found(it) } - baseEntity is EntityDragon -> MobResult.found(MobFactories.basic(baseEntity, baseEntity.cleanName())) + baseEntity is EntityDragon -> when (LorenzUtils.skyBlockIsland) { + IslandType.CATACOMBS -> (8..16).map { MobUtils.getArmorStand(baseEntity, it) } + .makeMobResult { + MobFactories.boss(baseEntity, it.first(), it.drop(1)) + } + + else -> MobResult.found(MobFactories.basic(baseEntity, baseEntity.cleanName())) + } + baseEntity is EntityGiantZombie && baseEntity.name == "Dinnerbone" -> MobResult.found( MobFactories.projectile( baseEntity, @@ -229,6 +238,13 @@ object MobFilter { ) ) + baseEntity is EntityOtherPlayerMP && baseEntity.name == "Decoy " -> MobResult.found( + MobFactories.special( + baseEntity, + "Decoy" + ) + ) + else -> null } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index d37ddad09..a9f5ec6c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -163,4 +163,12 @@ object CollectionUtils { this.add(newValue) true } else false + + @Suppress("UNCHECKED_CAST") + fun Iterable.takeIfAllNotNull(): Iterable? = + takeIf { null !in this } as? Iterable + + @Suppress("UNCHECKED_CAST") + fun List.takeIfAllNotNull(): List? = + takeIf { null !in this } as? List } -- cgit