fix: aura attacks closest target
This commit is contained in:
parent
954a8c806f
commit
434b0cc0cc
1 changed files with 14 additions and 5 deletions
|
@ -129,6 +129,9 @@ public class Aura extends QuickModule implements ICommons {
|
||||||
|
|
||||||
if (MC.player.getAttackStrengthScale(0.f) < this.strenght.get()) return;
|
if (MC.player.getAttackStrengthScale(0.f) < this.strenght.get()) return;
|
||||||
|
|
||||||
|
float distance = Float.MAX_VALUE;
|
||||||
|
Entity target = null;
|
||||||
|
|
||||||
for (Entity e : MC.level.entitiesForRendering()) {
|
for (Entity e : MC.level.entitiesForRendering()) {
|
||||||
if (e.equals(MC.player)) continue;
|
if (e.equals(MC.player)) continue;
|
||||||
if (!(e instanceof LivingEntity)) 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;
|
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()) {
|
switch (this.look.get()) {
|
||||||
case ONCE:
|
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()));
|
MC.player.connection.send(new CPlayerPacket.RotationPacket(MC.player.yRot, MC.player.xRot, MC.player.isOnGround()));
|
||||||
break;
|
break;
|
||||||
case PACKET:
|
case PACKET:
|
||||||
this.lookAtHidden(Type.EYES, e.getEyePosition(1.0F));
|
this.lookAtHidden(Type.EYES, target.getEyePosition(1.0F));
|
||||||
break;
|
break;
|
||||||
case NONE: break;
|
case NONE: break;
|
||||||
}
|
}
|
||||||
|
@ -157,12 +168,10 @@ public class Aura extends QuickModule implements ICommons {
|
||||||
if (this.tool.get()) {
|
if (this.tool.get()) {
|
||||||
this.autotool.selectBestWeapon();
|
this.autotool.selectBestWeapon();
|
||||||
}
|
}
|
||||||
MC.gameMode.attack(MC.player, e);
|
MC.gameMode.attack(MC.player, target);
|
||||||
if (this.swing.get()) {
|
if (this.swing.get()) {
|
||||||
MC.player.swing(Hand.MAIN_HAND);
|
MC.player.swing(Hand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
break; // TODO should find all valid targets and choose one rather than stopping here
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue