From 9f0e2d0f8971d25db5bdc77024b45d52c9a60287 Mon Sep 17 00:00:00 2001 From: TwinkNet <248537975+TwinkNet@users.noreply.github.com> Date: Thu, 12 Mar 2026 01:12:08 -0600 Subject: [PATCH 1/4] Fix - KillAura cannot target projectiles and other non-living entities. --- .../com/lambda/config/groups/Targeting.kt | 24 +++++++++---------- .../module/modules/combat/CrystalAura.kt | 2 +- .../lambda/module/modules/combat/KillAura.kt | 6 ++--- .../module/modules/movement/BackTrack.kt | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index 7163303e8..181310f74 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -26,15 +26,13 @@ import com.lambda.interaction.managers.rotating.Rotation.Companion.dist import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.threading.runSafe -import com.lambda.util.EntityUtils.EntityGroup -import com.lambda.util.EntityUtils.entityGroup import com.lambda.util.NamedEnum import com.lambda.util.extension.fullHealth import com.lambda.util.math.distSq import com.lambda.util.world.fastEntitySearch import net.minecraft.client.network.ClientPlayerEntity import net.minecraft.client.network.OtherClientPlayerEntity -import net.minecraft.client.toast.SystemToast.hide +import net.minecraft.entity.Entity import net.minecraft.entity.LivingEntity import java.util.* @@ -76,7 +74,7 @@ abstract class Targeting( * @param entity The [LivingEntity] being evaluated. * @return `true` if the entity is valid for targeting, `false` otherwise. */ - open fun validate(player: ClientPlayerEntity, entity: LivingEntity) = + open fun validate(player: ClientPlayerEntity, entity: Entity) = targets.isSelected(entity) && (entity !is OtherClientPlayerEntity || !entity.isFriend) /** @@ -110,20 +108,20 @@ abstract class Targeting( * @param entity The [LivingEntity] being evaluated. * @return `true` if the entity is valid for targeting, `false` otherwise. */ - override fun validate(player: ClientPlayerEntity, entity: LivingEntity): Boolean { + override fun validate(player: ClientPlayerEntity, entity: Entity): Boolean { if (fov < 180 && player.rotation dist player.eyePos.rotationTo(entity.pos) > fov) return false if (entity.uuid in illegalTargets) return false - if (entity.isDead) return false + if ((entity as? LivingEntity)?.isDead == true) return false return super.validate(player, entity) } /** * Gets the best target for combat based on the current settings and priority. * - * @return The best [LivingEntity] target, or `null` if no valid target is found. + * @return The best [Entity] target, or `null` if no valid target is found. */ - fun target(): LivingEntity? = runSafe { - return@runSafe fastEntitySearch(targetingRange) { + inline fun target(): T? = runSafe { + return@runSafe fastEntitySearch(targetingRange) { validate(player, it) }.minByOrNull { priority.factor(this, it) @@ -140,10 +138,10 @@ abstract class Targeting( /** * Enum representing the different priority factors used for determining the best target. * - * @property factor A lambda function that calculates the priority factor for a given [LivingEntity]. + * @property factor A lambda function that calculates the priority factor for a given [Entity]. */ @Suppress("Unused") - enum class Priority(val factor: SafeContext.(LivingEntity) -> Double) { + enum class Priority(val factor: SafeContext.(Entity) -> Double) { /** * Prioritizes entities based on their distance from the player. */ @@ -151,8 +149,10 @@ abstract class Targeting( /** * Prioritizes entities based on their health. + * Entites that aren't an instanceof LivingEntity will be treated as if they are at 0 health, + * therefore having least priority */ - Health({ it.fullHealth }), + Health({ (it as? LivingEntity)?.fullHealth ?: 0.0 }), /** * Prioritizes entities based on their angle relative to the player's field of view. diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index c43c70eb1..423f25e5f 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -245,7 +245,7 @@ object CrystalAura : Module( private fun SafeContext.tick() { // Update the target - currentTarget = targeting.target() + currentTarget = targeting.target() // Update the blueprint currentTarget?.let { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index eb666107e..0edb2f756 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -36,7 +36,7 @@ import com.lambda.util.item.ItemStackUtils.attackDamage import com.lambda.util.item.ItemStackUtils.attackSpeed import com.lambda.util.math.random import com.lambda.util.player.SlotUtils.hotbarStacks -import net.minecraft.entity.LivingEntity +import net.minecraft.entity.Entity import net.minecraft.item.ItemStack import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket import net.minecraft.util.Hand @@ -59,8 +59,8 @@ object KillAura : Module( // Targeting private val targeting = Targeting.Combat(c = this, baseGroup = arrayOf(Group.Targeting)) - val target: LivingEntity? - get() = targeting.target() + val target: Entity? + get() = targeting.target() private var prevEntity = target private var validServerRot = false diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt index 53006851b..70b0e687a 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt @@ -95,7 +95,7 @@ object BackTrack : Module( init { listen { val prevTarget = target - target = if (KillAura.isDisabled) null else KillAura.target + target = KillAura.target.takeIf { KillAura.isEnabled } as? LivingEntity val currentTarget = target if (prevTarget != currentTarget || currentTarget == null) { From 8794f3287c24757b356a7890b57cd3d893e121fa Mon Sep 17 00:00:00 2001 From: TwinkNet <248537975+TwinkNet@users.noreply.github.com> Date: Thu, 12 Mar 2026 01:38:13 -0600 Subject: [PATCH 2/4] update documentation for Targeting.validate() --- src/main/kotlin/com/lambda/config/groups/Targeting.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index 181310f74..5b22f6306 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -105,7 +105,7 @@ abstract class Targeting( * Validates whether a given entity is targetable for combat based on the field of view limit and other settings. * * @param player The [ClientPlayerEntity] performing the targeting. - * @param entity The [LivingEntity] being evaluated. + * @param entity The [Entity] being evaluated. * @return `true` if the entity is valid for targeting, `false` otherwise. */ override fun validate(player: ClientPlayerEntity, entity: Entity): Boolean { From 6810e857fc767ecfe7bd88edbe8016a00d15508b Mon Sep 17 00:00:00 2001 From: TwinkNet <248537975+TwinkNet@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:02:27 -0600 Subject: [PATCH 3/4] Targeting by health should always prioritise LivingEntity --- src/main/kotlin/com/lambda/config/groups/Targeting.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index 5b22f6306..92ee39044 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -149,10 +149,10 @@ abstract class Targeting( /** * Prioritizes entities based on their health. - * Entites that aren't an instanceof LivingEntity will be treated as if they are at 0 health, + * Entites that aren't an instanceof LivingEntity will be treated as if they have Double.MAX_VALUE health, * therefore having least priority */ - Health({ (it as? LivingEntity)?.fullHealth ?: 0.0 }), + Health({ (it as? LivingEntity)?.fullHealth ?: Double.MAX_VALUE }), /** * Prioritizes entities based on their angle relative to the player's field of view. From e079dab27a93731daf05fd758f41f515938f1909 Mon Sep 17 00:00:00 2001 From: TwinkNet <248537975+TwinkNet@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:05:16 -0600 Subject: [PATCH 4/4] fix typo in docs --- src/main/kotlin/com/lambda/config/groups/Targeting.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index 92ee39044..7cc483ff8 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -149,7 +149,7 @@ abstract class Targeting( /** * Prioritizes entities based on their health. - * Entites that aren't an instanceof LivingEntity will be treated as if they have Double.MAX_VALUE health, + * Entities that aren't an instanceof LivingEntity will be treated as if they have Double.MAX_VALUE health, * therefore having least priority */ Health({ (it as? LivingEntity)?.fullHealth ?: Double.MAX_VALUE }),