diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java index cad15d2..3b258d6 100644 --- a/src/main/java/ftbsc/bscv/BoSCoVicino.java +++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java @@ -33,6 +33,7 @@ import ftbsc.bscv.modules.vision.*; import ftbsc.bscv.modules.motion.*; import ftbsc.bscv.modules.self.*; import ftbsc.bscv.modules.hud.*; +import ftbsc.bscv.modules.defense.*; // The value here should match an entry in the META-INF/mods.toml file @Mod("bscv") @@ -73,6 +74,7 @@ public class BoSCoVicino implements ICommons { BoSCoVicino.mods.add(new AutoTool(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new BoatFly(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new Aura(cfg, dp).done(cfg)); BoSCoVicino.spec = cfg.build(); diff --git a/src/main/java/ftbsc/bscv/modules/defense/Aura.java b/src/main/java/ftbsc/bscv/modules/defense/Aura.java new file mode 100644 index 0000000..813b3ef --- /dev/null +++ b/src/main/java/ftbsc/bscv/modules/defense/Aura.java @@ -0,0 +1,54 @@ +package ftbsc.bscv.modules.defense; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.DoubleArgumentType; + +import ftbsc.bscv.ICommons; +import ftbsc.bscv.modules.QuickModule; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.TickEvent.Phase; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +public class Aura extends QuickModule implements ICommons { + + public final ForgeConfigSpec.ConfigValue reach; + public final ForgeConfigSpec.ConfigValue strenght; + + public Aura(ForgeConfigSpec.Builder builder, CommandDispatcher dispatcher) { + super("Aura", Group.DEFENSE, UNBOUND, builder, dispatcher); + + this.reach = this.option( + "reach", "aura attack reach", 5., + DoubleArgumentType.doubleArg(0.), Double.class, + builder, dispatcher + ); + + this.strenght = this.option( + "strenght", "minimum strenght required for attack", 1., + DoubleArgumentType.doubleArg(0., 1.), Double.class, + builder, dispatcher + ); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase == Phase.END) return; + if (MC.level == null) return; + if (MC.player == null) return; + + if (MC.player.getAttackStrengthScale(0.f) < this.strenght.get()) return; + + for (Entity e : MC.level.entitiesForRendering()) { + if (e.equals(MC.player)) continue; + if (!(e instanceof LivingEntity)) continue; + if (!e.isAlive()) continue; + if (e.distanceTo(MC.player) > this.reach.get()) continue; + MC.gameMode.attack(MC.player, e); + break; + } + } +}