From 74b18c1f246855d2a70ece6e96b381345f721a85 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:15:40 +0200 Subject: Fix: Wierd default Armorstand value (#1495) --- src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt | 2 ++ src/main/java/at/hannibal2/skyhanni/utils/MobUtils.kt | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt index 5629eefcf..80eee1f2d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.refreshReference import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.MobUtils import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.EntityLivingBase @@ -68,6 +69,7 @@ class MobDetection { MobFilter.wokeSleepingGolemPattern MobFilter.jerryPattern MobFilter.jerryMagmaCubePattern + MobUtils.defaultArmorStandName } private fun mobDetectionReset() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MobUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/MobUtils.kt index 1c632bcee..6aff6406d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MobUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MobUtils.kt @@ -5,13 +5,15 @@ import at.hannibal2.skyhanni.data.mob.MobData import at.hannibal2.skyhanni.utils.EntityUtils.cleanName import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LocationUtils.rayIntersects +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.player.EntityPlayer object MobUtils { - private const val defaultArmorStandName = "Armor Stand" + val defaultArmorStandName by RepoPattern.pattern("armorstand.default", "Armou?r Stand") // The corresponding ArmorStand for a mob has always the ID + 1 (with some exceptions) fun getArmorStand(entity: Entity, offset: Int = 1) = getNextEntity(entity, offset) as? EntityArmorStand @@ -28,7 +30,7 @@ object MobUtils { getArmorStandByRangeAll(entity, range).filter { it.cleanName().startsWith(name) } .sortedBy { it.distanceTo(entity) }.firstOrNull() - fun EntityArmorStand.isDefaultValue() = this.name == defaultArmorStandName + fun EntityArmorStand.isDefaultValue() = defaultArmorStandName.matches(this.name) fun EntityArmorStand?.takeNonDefault() = this?.takeIf { !it.isDefaultValue() } @@ -54,7 +56,7 @@ object MobUtils { entity: Entity, distance: Double, partialTicks: Float, - offset: LorenzVec = LorenzVec() + offset: LorenzVec = LorenzVec(), ) = rayTraceForMobs(entity, partialTicks, offset)?.filter { it.baseEntity.distanceTo(entity.getLorenzVec()) <= distance -- cgit