From 70fbe44ef1c5ea4c3533bc586a29a4879bb8d68e Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 3 Jun 2024 11:25:42 +0200 Subject: [PATCH] implement distance checking for killaura --- .../client/feature/combat/AutoKill.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Client/src/main/java/com/baseband/client/feature/combat/AutoKill.java b/Client/src/main/java/com/baseband/client/feature/combat/AutoKill.java index 87cf017..6da4f93 100644 --- a/Client/src/main/java/com/baseband/client/feature/combat/AutoKill.java +++ b/Client/src/main/java/com/baseband/client/feature/combat/AutoKill.java @@ -10,6 +10,8 @@ import de.tudbut.parsing.TCN; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; import java.util.ArrayList; @@ -74,7 +76,20 @@ public class AutoKill extends Feature { @Override public void onTick() { - ArrayList attackable = getAttackable(); + Vec3d eyePos = mc.player.getPositionEyes(1f); + ArrayList attackable = getAttackable(); + for (int i = 0; i < attackable.size(); i++) { + EntityLivingBase elb = attackable.get(i); + AxisAlignedBB boundingBox = elb.getEntityBoundingBox(); + double dminsq = getDminsq(boundingBox, eyePos); + if (dminsq > 3 * 3) { + attackable.remove(i--); + } + } + if(attackable.isEmpty()) + return; + + } @Override @@ -87,6 +102,20 @@ public class AutoKill extends Feature { return false; } } + + private static double getDminsq(AxisAlignedBB boundingBox, Vec3d eyePos) { + double dmx = Double.MAX_VALUE; + dmx = Math.min(Math.abs(boundingBox.maxX - eyePos.x), dmx); + dmx = Math.min(Math.abs(boundingBox.minX - eyePos.x), dmx); + double dmy = Double.MAX_VALUE; + dmy = Math.min(Math.abs(boundingBox.maxY - eyePos.y), dmy); + dmy = Math.min(Math.abs(boundingBox.minY - eyePos.y), dmy); + double dmz = Double.MAX_VALUE; + dmz = Math.min(Math.abs(boundingBox.maxZ - eyePos.z), dmz); + dmz = Math.min(Math.abs(boundingBox.minZ - eyePos.z), dmz); + return dmx * dmx + dmy * dmy + dmz * dmz; + } + @Combat public class AutoCrystal extends Feature {