fix: aura attacks closest target

This commit is contained in:
əlemi 2023-06-21 00:03:03 +02:00
parent 954a8c806f
commit 434b0cc0cc
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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
}
}
}