feat: added super basic aura module

This commit is contained in:
əlemi 2023-02-20 02:29:35 +01:00
parent 2c7dbb310a
commit a3491632e7
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 56 additions and 0 deletions

View file

@ -33,6 +33,7 @@ import ftbsc.bscv.modules.vision.*;
import ftbsc.bscv.modules.motion.*; import ftbsc.bscv.modules.motion.*;
import ftbsc.bscv.modules.self.*; import ftbsc.bscv.modules.self.*;
import ftbsc.bscv.modules.hud.*; import ftbsc.bscv.modules.hud.*;
import ftbsc.bscv.modules.defense.*;
// The value here should match an entry in the META-INF/mods.toml file // The value here should match an entry in the META-INF/mods.toml file
@Mod("bscv") @Mod("bscv")
@ -73,6 +74,7 @@ public class BoSCoVicino implements ICommons {
BoSCoVicino.mods.add(new AutoTool(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new AutoTool(cfg, dp).done(cfg));
BoSCoVicino.mods.add(new Freecam(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 BoatFly(cfg, dp).done(cfg));
BoSCoVicino.mods.add(new Aura(cfg, dp).done(cfg));
BoSCoVicino.spec = cfg.build(); BoSCoVicino.spec = cfg.build();

View file

@ -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<Double> reach;
public final ForgeConfigSpec.ConfigValue<Double> strenght;
public Aura(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> 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;
}
}
}