aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-06-21 00:03:03 +0200
committer alemi <me@alemi.dev>2023-06-21 00:03:03 +0200
commit434b0cc0cc7e2359b51eb2d6a0bea40be25acef6 (patch)
tree565c40e1f6a67698b4255e32b38e6d5ee0f0de26 /src
parent954a8c806fabeabba436f9b158e835b9eaeee621 (diff)
fix: aura attacks closest target
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/bscv/modules/defense/Aura.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/defense/Aura.java b/src/main/java/ftbsc/bscv/modules/defense/Aura.java
index 290ab81..3ebe569 100644
--- a/src/main/java/ftbsc/bscv/modules/defense/Aura.java
+++ b/src/main/java/ftbsc/bscv/modules/defense/Aura.java
@@ -129,6 +129,9 @@ public class Aura extends QuickModule implements ICommons {
if (MC.player.getAttackStrengthScale(0.f) < this.strenght.get()) return;
+ float distance = Float.MAX_VALUE;
+ Entity target = null;
+
for (Entity e : MC.level.entitiesForRendering()) {
if (e.equals(MC.player)) continue;
if (!(e instanceof LivingEntity)) continue;
@@ -143,13 +146,21 @@ public class Aura extends QuickModule implements ICommons {
}
if (this.trace.get() && !MC.player.canSee(e)) continue;
+ float dist = MC.player.distanceTo(e);
+ if (dist < distance) {
+ distance = dist;
+ target = e;
+ }
+ }
+
+ if (target != null) {
switch (this.look.get()) {
case ONCE:
- MC.player.lookAt(Type.EYES, e.getEyePosition(1.0F));
+ MC.player.lookAt(Type.EYES, target.getEyePosition(1.0F));
MC.player.connection.send(new CPlayerPacket.RotationPacket(MC.player.yRot, MC.player.xRot, MC.player.isOnGround()));
break;
case PACKET:
- this.lookAtHidden(Type.EYES, e.getEyePosition(1.0F));
+ this.lookAtHidden(Type.EYES, target.getEyePosition(1.0F));
break;
case NONE: break;
}
@@ -157,12 +168,10 @@ public class Aura extends QuickModule implements ICommons {
if (this.tool.get()) {
this.autotool.selectBestWeapon();
}
- MC.gameMode.attack(MC.player, e);
+ MC.gameMode.attack(MC.player, target);
if (this.swing.get()) {
MC.player.swing(Hand.MAIN_HAND);
}
-
- break; // TODO should find all valid targets and choose one rather than stopping here
}
}
}