feat: added trace, look, tool options to aura
option to check for visibility, option to change player rotation before attacking, option to switch to best tool
This commit is contained in:
parent
c13aa88bbd
commit
5ac2a187ba
1 changed files with 82 additions and 2 deletions
|
@ -6,10 +6,17 @@ import ftbsc.bscv.Boscovicino;
|
|||
import ftbsc.bscv.ICommons;
|
||||
import ftbsc.bscv.api.ILoadable;
|
||||
import ftbsc.bscv.modules.QuickModule;
|
||||
import ftbsc.bscv.modules.self.AutoTool;
|
||||
import ftbsc.bscv.tools.Setting;
|
||||
import net.minecraft.command.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.command.arguments.EntityAnchorArgument.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.play.client.CPlayerPacket;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
|
@ -18,6 +25,13 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||
@AutoService(ILoadable.class)
|
||||
public class Aura extends QuickModule implements ICommons {
|
||||
|
||||
private enum LookType {
|
||||
NONE,
|
||||
PACKET,
|
||||
ONCE,
|
||||
// RESET
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefaultKey() {
|
||||
return UNBOUND;
|
||||
|
@ -25,9 +39,15 @@ public class Aura extends QuickModule implements ICommons {
|
|||
|
||||
public final ForgeConfigSpec.ConfigValue<Double> reach;
|
||||
public final ForgeConfigSpec.ConfigValue<Double> strenght;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> tool;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> trace;
|
||||
public final ForgeConfigSpec.ConfigValue<LookType> look;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> swing;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> neutral;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> friends;
|
||||
|
||||
private AutoTool autotool;
|
||||
|
||||
public Aura() {
|
||||
super();
|
||||
|
||||
|
@ -46,6 +66,30 @@ public class Aura extends QuickModule implements ICommons {
|
|||
.fallback(1.)
|
||||
.build(this);
|
||||
|
||||
this.tool = Setting.Bool.builder()
|
||||
.fallback(true)
|
||||
.name("tool")
|
||||
.comment("trigger AutoTool when attacking")
|
||||
.build(this);
|
||||
|
||||
this.trace = Setting.Bool.builder()
|
||||
.fallback(true)
|
||||
.name("trace")
|
||||
.comment("make sure mobs are visible before hitting")
|
||||
.build(this);
|
||||
|
||||
this.look = Setting.Switch.builder(LookType.class)
|
||||
.fallback(LookType.PACKET)
|
||||
.name("look")
|
||||
.comment("look at mobs before attacking them")
|
||||
.build(this);
|
||||
|
||||
this.swing = Setting.Bool.builder()
|
||||
.fallback(true)
|
||||
.name("swing")
|
||||
.comment("swing arm when attacking")
|
||||
.build(this);
|
||||
|
||||
this.neutral = Setting.Bool.builder()
|
||||
.fallback(false)
|
||||
.name("neutral")
|
||||
|
@ -59,6 +103,23 @@ public class Aura extends QuickModule implements ICommons {
|
|||
.build(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnabled() {
|
||||
this.autotool = (AutoTool) Boscovicino.modManager.get(AutoTool.class);
|
||||
}
|
||||
|
||||
private void lookAtHidden(EntityAnchorArgument.Type anchor, Vector3d target) {
|
||||
// This code comes from vanilla Minecraft, but we send a packet rather than turning player
|
||||
Vector3d translated = anchor.apply(MC.player);
|
||||
double d0 = target.x - translated.x;
|
||||
double d1 = target.y - translated.y;
|
||||
double d2 = target.z - translated.z;
|
||||
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
float xRot = MathHelper.wrapDegrees((float)(-(MathHelper.atan2(d1, d3) * (double)(180F / (float)Math.PI))));
|
||||
float yRot = MathHelper.wrapDegrees((float)(MathHelper.atan2(d2, d0) * (double)(180F / (float)Math.PI)) - 90.0F);
|
||||
MC.player.connection.send(new CPlayerPacket.RotationPacket(yRot, xRot, MC.player.isOnGround()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == Phase.END) return;
|
||||
|
@ -79,9 +140,28 @@ public class Aura extends QuickModule implements ICommons {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (!this.friends.get() && Boscovicino.friends().isFriend(e.getDisplayName().getString())) continue;
|
||||
if (this.trace.get() && !MC.player.canSee(e)) continue;
|
||||
|
||||
switch (this.look.get()) {
|
||||
case ONCE:
|
||||
MC.player.lookAt(Type.EYES, e.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));
|
||||
break;
|
||||
case NONE: break;
|
||||
}
|
||||
|
||||
if (this.tool.get()) {
|
||||
this.autotool.selectBestWeapon();
|
||||
}
|
||||
MC.gameMode.attack(MC.player, e);
|
||||
break;
|
||||
if (this.swing.get()) {
|
||||
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