summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-02-28 21:16:05 +0100
committer zaaarf <zaaarf@proton.me>2023-02-28 21:16:05 +0100
commit4359e3d285774ced2ebd8662b82f8b5c41fb51a9 (patch)
tree48d869921ea12201b2194827f4a1c9b077821a55 /src/main/java
parent3be09e93843986e9ccf056d712f0cd1bedb0fd6e (diff)
feat: implemented basic interface structure and made module constructors with no params
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/ftbsc/bscv/BoSCoVicino.java55
-rw-r--r--src/main/java/ftbsc/bscv/api/ICommand.java8
-rw-r--r--src/main/java/ftbsc/bscv/api/ILoadable.java5
-rw-r--r--src/main/java/ftbsc/bscv/api/IModule.java17
-rw-r--r--src/main/java/ftbsc/bscv/modules/AbstractModule.java61
-rw-r--r--src/main/java/ftbsc/bscv/modules/HudModule.java24
-rw-r--r--src/main/java/ftbsc/bscv/modules/QuickModule.java14
-rw-r--r--src/main/java/ftbsc/bscv/modules/defense/Aura.java24
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java23
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/Coordinates.java7
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/EntityList.java11
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java16
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/PlayerList.java6
-rw-r--r--src/main/java/ftbsc/bscv/modules/motion/BoatFly.java33
-rw-r--r--src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java28
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/AntiHunger.java24
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java20
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/AutoFish.java22
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/AutoTool.java23
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/FastInteract.java18
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/Freecam.java25
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/PortalGui.java18
-rw-r--r--src/main/java/ftbsc/bscv/modules/vision/Fullbright.java28
-rw-r--r--src/main/java/ftbsc/bscv/system/ModManager.java42
-rw-r--r--src/main/java/ftbsc/bscv/tools/Setting.java9
25 files changed, 368 insertions, 193 deletions
diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java
index 3b258d6..a3911c0 100644
--- a/src/main/java/ftbsc/bscv/BoSCoVicino.java
+++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java
@@ -1,5 +1,7 @@
package ftbsc.bscv;
+import ftbsc.bscv.api.IModule;
+import ftbsc.bscv.system.ModManager;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.IngameMenuScreen;
import net.minecraft.client.gui.widget.button.Button;
@@ -25,56 +27,49 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import ftbsc.bscv.modules.Module;
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")
public class BoSCoVicino implements ICommons {
public static String MOD_ID = "bscv";
- // Directly reference a log4j logger.
public static final Logger LOGGER = LogManager.getLogger();
- public static List<Module> mods;
+ public static ModManager modManager; //todo this should not be static
private final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
public static ForgeConfigSpec spec;
public BoSCoVicino() {
- // Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
- // load and register mods
- BoSCoVicino.mods = new ArrayList<Module>();
-
ForgeConfigSpec.Builder cfg = new ForgeConfigSpec.Builder();
CommandDispatcher<CommandSource> dp = this.dispatcher;
- BoSCoVicino.mods.add(new AutoDisconnect(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new ActiveModules(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new VanillaFlight(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new FastInteract(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new InfoDisplay(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new Coordinates(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new PlayerList(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new PortalGui(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new AutoFish(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 BoatFly(cfg, dp).done(cfg));
- BoSCoVicino.mods.add(new Aura(cfg, dp).done(cfg));
+ this.modManager = new ModManager(cfg, dp);
+
+ this.modManager.registerMod(new AutoDisconnect());
+ this.modManager.registerMod(new ActiveModules());
+ this.modManager.registerMod(new VanillaFlight());
+ this.modManager.registerMod(new FastInteract());
+ this.modManager.registerMod(new InfoDisplay());
+ this.modManager.registerMod(new Coordinates());
+ this.modManager.registerMod(new EntityList());
+ this.modManager.registerMod(new PlayerList());
+ this.modManager.registerMod(new Fullbright());
+ this.modManager.registerMod(new AntiHunger());
+ this.modManager.registerMod(new PortalGui());
+ this.modManager.registerMod(new AutoFish());
+ this.modManager.registerMod(new AutoTool());
+ this.modManager.registerMod(new Freecam());
+ this.modManager.registerMod(new BoatFly());
+ this.modManager.registerMod(new Aura());
BoSCoVicino.spec = cfg.build();
@@ -95,8 +90,8 @@ public class BoSCoVicino implements ICommons {
private void clientSetup(final FMLClientSetupEvent event) {
LOGGER.info("Initializing modules");
- for (Module m : BoSCoVicino.mods) {
- if (m.enabled.get()) m.enable();
+ for (IModule<?> m : modManager.mods) {
+ if (m.isEnabled()) m.enable();
}
// TEMPORARY! add command to regenerate suggestions
@@ -132,8 +127,8 @@ public class BoSCoVicino implements ICommons {
dispatcher.register(
Commands.literal("toggle-all")
.executes(ctx -> {
- for (Module mod : BoSCoVicino.mods) {
- if (mod.enabled.get()) {
+ for (IModule<?> mod : modManager.mods) {
+ if (mod.isEnabled()) {
mod.disable();
mod.enable();
}
diff --git a/src/main/java/ftbsc/bscv/api/ICommand.java b/src/main/java/ftbsc/bscv/api/ICommand.java
new file mode 100644
index 0000000..24e309c
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/api/ICommand.java
@@ -0,0 +1,8 @@
+package ftbsc.bscv.api;
+
+import com.mojang.brigadier.CommandDispatcher;
+import net.minecraft.command.CommandSource;
+
+public interface ICommand extends ILoadable {
+ CommandDispatcher<CommandSource> getDispatcher();
+}
diff --git a/src/main/java/ftbsc/bscv/api/ILoadable.java b/src/main/java/ftbsc/bscv/api/ILoadable.java
new file mode 100644
index 0000000..e39caec
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/api/ILoadable.java
@@ -0,0 +1,5 @@
+package ftbsc.bscv.api;
+
+public interface ILoadable {
+ String getName();
+}
diff --git a/src/main/java/ftbsc/bscv/api/IModule.java b/src/main/java/ftbsc/bscv/api/IModule.java
new file mode 100644
index 0000000..a6a6d12
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/api/IModule.java
@@ -0,0 +1,17 @@
+package ftbsc.bscv.api;
+
+import net.minecraftforge.common.ForgeConfigSpec;
+
+public interface IModule<T extends Enum<T>> extends ICommand {
+ T getGroup();
+
+ ForgeConfigSpec.Builder getConfigBuilder();
+
+ void toggle();
+
+ void enable();
+
+ void disable();
+
+ boolean isEnabled();
+}
diff --git a/src/main/java/ftbsc/bscv/modules/AbstractModule.java b/src/main/java/ftbsc/bscv/modules/AbstractModule.java
index b17f3b3..7e6d2a6 100644
--- a/src/main/java/ftbsc/bscv/modules/AbstractModule.java
+++ b/src/main/java/ftbsc/bscv/modules/AbstractModule.java
@@ -3,6 +3,9 @@ package ftbsc.bscv.modules;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
+import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.api.IModule;
+import ftbsc.bscv.system.ModManager;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -10,7 +13,7 @@ import net.minecraftforge.common.MinecraftForge;
import static ftbsc.bscv.BoSCoVicino.log;
-public abstract class AbstractModule {
+public abstract class AbstractModule implements IModule<AbstractModule.Group> {
public enum Group {
SELF,
HUD,
@@ -20,20 +23,27 @@ public abstract class AbstractModule {
MOTION,
}
- public final String name;
- public final Group group;
-
protected ForgeConfigSpec.ConfigValue<Boolean> enabled;
- public void initialize(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- builder.push(this.name.toLowerCase());
- this.enabled = builder
- .comment(String.format("Enables %s", this.name))
+ @Override
+ public ForgeConfigSpec.Builder getConfigBuilder() {
+ return BoSCoVicino.modManager.getCfgBuilder();
+ }
+
+ @Override
+ public CommandDispatcher<CommandSource> getDispatcher() {
+ return BoSCoVicino.modManager.getDispatcher();
+ }
+
+ public AbstractModule() {
+ this.getConfigBuilder().push(this.getName().toLowerCase());
+ this.enabled = this.getConfigBuilder()
+ .comment(String.format("Enables %s", this.getName()))
.define("enabled", false);
// TODO: can this be made an util or moved somewhere else?
- dispatcher.register(
- Commands.literal(this.name.toLowerCase())
+ this.getDispatcher().register(
+ Commands.literal(this.getName().toLowerCase())
.then(
Commands.literal("toggle")
.then(
@@ -53,31 +63,13 @@ public abstract class AbstractModule {
})
)
.executes(ctx -> {
- log(String.format("%s [%s]", this.name, this.enabled.get() ? "ON" : "OFF"));
+ log(String.format("%s [%s]", this.getName(), this.enabled.get() ? "ON" : "OFF"));
// TODO: print all mod options!
return 1;
})
);
- this.register(builder, dispatcher);
-
- builder.pop();
- }
-
- public abstract void register(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher);
-
- protected AbstractModule(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- // TODO can this be done in a less magic way?
- String[] pkg = this.getClass().getPackage().getName().split(".");
- this.group = Group.valueOf(pkg[pkg.length-1].toUpperCase());
- this.name = this.getClass().getName();
-
- this.initialize(builder, dispatcher);
- }
-
- public AbstractModule done(ForgeConfigSpec.Builder builder) {
- builder.pop();
- return this;
+ this.getConfigBuilder().pop();
}
protected void onEnabled() {}
@@ -93,7 +85,7 @@ public abstract class AbstractModule {
this.enabled.set(true);
// this.enabled.save();
this.onEnabled();
- log(String.format("%s ON", this.name));
+ log(String.format("%s ON", this.getName()));
}
public final void disable() {
@@ -101,6 +93,11 @@ public abstract class AbstractModule {
this.enabled.set(false);
// this.enabled.save();
this.onDisabled();
- log(String.format("%s OFF", this.name));
+ log(String.format("%s OFF", this.getName()));
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled.get();
}
}
diff --git a/src/main/java/ftbsc/bscv/modules/HudModule.java b/src/main/java/ftbsc/bscv/modules/HudModule.java
index 4a893fb..52cba0c 100644
--- a/src/main/java/ftbsc/bscv/modules/HudModule.java
+++ b/src/main/java/ftbsc/bscv/modules/HudModule.java
@@ -8,46 +8,46 @@ import ftbsc.bscv.tools.Setting;
import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec;
-public abstract class HudModule extends Module {
+public abstract class HudModule extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Integer> x;
public final ForgeConfigSpec.ConfigValue<Integer> y;
public final ForgeConfigSpec.ConfigValue<Double> scale;
public final ForgeConfigSpec.ConfigValue<Anchor> anchor;
- protected HudModule(String name, ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super(name, Group.HUD, builder, dispatcher);
+ @Override
+ public Group getGroup() {
+ return Group.HUD;
+ }
+ protected HudModule() {
+ super();
this.x = Setting.Number.builder()
.name("x")
.comment("horizontal offset")
.fallback(0)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.y = Setting.Number.builder()
.name("y")
.comment("vertical offset")
.fallback(0)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.scale = Setting.Decimal.builder()
.name("scale")
.comment("scale of element")
.fallback(1.0)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.anchor = Setting.Switch.builder(Anchor.class)
.name("anchor")
.comment("origin point for coordinates")
.fallback(Anchor.TOPLEFT)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
protected boolean shouldHide() {
- if (ICommons.MC.options.renderDebug) {
- return true;
- }
-
- return false;
+ return ICommons.MC.options.renderDebug;
}
}
diff --git a/src/main/java/ftbsc/bscv/modules/QuickModule.java b/src/main/java/ftbsc/bscv/modules/QuickModule.java
index a54a3e9..5e06ea5 100644
--- a/src/main/java/ftbsc/bscv/modules/QuickModule.java
+++ b/src/main/java/ftbsc/bscv/modules/QuickModule.java
@@ -14,17 +14,17 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
import ftbsc.bscv.BoSCoVicino;
// TODO rename
-public class QuickModule extends Module {
+public abstract class QuickModule extends AbstractModule {
public static final int UNBOUND = InputMappings.UNKNOWN.getValue();
private class ToggleHook {
private final KeyBinding key;
- private final Module mod;
+ private final QuickModule mod;
private boolean debounce;
// TODO all examples show isPressed() to get a debounced value
// but it seems to be missing? making my own debounce for now
- protected ToggleHook(KeyBinding key, Module mod) {
+ protected ToggleHook(KeyBinding key, QuickModule mod) {
this.key = key;
this.mod = mod;
this.debounce = false;
@@ -50,11 +50,13 @@ public class QuickModule extends Module {
}
public final KeyBinding keybind;
+
+ protected abstract int getDefaultKey();
- public QuickModule(String name, Group group, int default_key, ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super(name, group, builder, dispatcher);
+ public QuickModule() {
+ super();
- this.keybind = new KeyBinding(key_name(name), default_key, key_category());
+ this.keybind = new KeyBinding(key_name(this.getName()), this.getDefaultKey(), key_category());
ClientRegistry.registerKeyBinding(this.keybind);
// register a separate subclass on the hook, so that it's always listening
diff --git a/src/main/java/ftbsc/bscv/modules/defense/Aura.java b/src/main/java/ftbsc/bscv/modules/defense/Aura.java
index 0976f22..9bb3f25 100644
--- a/src/main/java/ftbsc/bscv/modules/defense/Aura.java
+++ b/src/main/java/ftbsc/bscv/modules/defense/Aura.java
@@ -1,7 +1,6 @@
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;
@@ -16,18 +15,33 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class Aura extends QuickModule implements ICommons {
+ @Override
+ public String getName() {
+ return "Aura";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.DEFENSE;
+ }
+
+ @Override
+ protected int getDefaultKey() {
+ return UNBOUND;
+ }
+
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);
+ public Aura() {
+ super();
this.reach = Setting.Decimal.builder()
.min(0.)
.fallback(5.)
.name("reach")
.comment("aura attack reach")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.strenght = Setting.Decimal.builder()
.min(0.)
@@ -35,7 +49,7 @@ public class Aura extends QuickModule implements ICommons {
.name("strenght")
.comment("minimum strenght required for attack")
.fallback(1.)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java b/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java
index 069f912..d754ee9 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java
@@ -1,33 +1,30 @@
package ftbsc.bscv.modules.hud;
-import static ftbsc.bscv.tools.Text.TextBuilder;
-
-import com.mojang.brigadier.CommandDispatcher;
-
import ftbsc.bscv.BoSCoVicino;
import ftbsc.bscv.ICommons;
-import net.minecraft.command.CommandSource;
+import ftbsc.bscv.api.IModule;
+import ftbsc.bscv.modules.HudModule;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
-import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-import ftbsc.bscv.modules.HudModule;
-import ftbsc.bscv.modules.Module;
+
+import static ftbsc.bscv.tools.Text.TextBuilder;
public class ActiveModules extends HudModule implements ICommons {
- public ActiveModules(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("ActiveModules", builder, dispatcher);
+ @Override
+ public String getName() {
+ return "ActiveModules";
}
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() == ElementType.TEXT) {
int offset = 0;
- for (Module m : BoSCoVicino.mods) {
- if (m.enabled.get() && m.group != Group.HUD) {
+ for (IModule<?> m : BoSCoVicino.modManager.mods) {
+ if (m.isEnabled() && m.getGroup() != Group.HUD) {
TextBuilder()
- .txt(String.format("%s <", m.name))
+ .txt(String.format("%s <", m.getName()))
.anchor(this.anchor.get())
.x(this.x.get())
.y(this.y.get() + offset)
diff --git a/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java b/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java
index c034756..bf6923d 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java
@@ -14,9 +14,10 @@ import ftbsc.bscv.ICommons;
import ftbsc.bscv.modules.HudModule;
public class Coordinates extends HudModule implements ICommons {
-
- public Coordinates(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("Coordinates", builder, dispatcher);
+
+ @Override
+ public String getName() {
+ return "Coordinates";
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
index ae58ce1..954e8b7 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
@@ -24,16 +24,21 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class EntityList extends HudModule implements ICommons {
+ @Override
+ public String getName() {
+ return "EntityList";
+ }
+
public final ForgeConfigSpec.ConfigValue<String> search;
- public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("EntityList", builder, dispatcher);
+ public EntityList() {
+ super();
this.search = Setting.Str.builder()
.name("search")
.comment("highlight names containing this text")
.fallback("")
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java
index 22e1bf2..240ce83 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java
@@ -23,6 +23,10 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class InfoDisplay extends HudModule implements ICommons {
+ @Override
+ public String getName() {
+ return "InfoDisplay";
+ }
private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0);
private double instant_speed = 0.0;
@@ -45,32 +49,32 @@ public class InfoDisplay extends HudModule implements ICommons {
// public final ForgeConfigSpec.ConfigValue<Boolean> client_chunk_size;
public final ForgeConfigSpec.ConfigValue<Boolean> hide_effects;
- public InfoDisplay(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("InfoDisplay", builder, dispatcher);
+ public InfoDisplay() {
+ super();
this.logo = Setting.Bool.builder()
.name("logo")
.comment("show logo at top of list")
.fallback(true)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.speed = Setting.Bool.builder()
.name("speed")
.comment("show speed meter")
.fallback(true)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.time = Setting.Bool.builder()
.name("time")
.comment("show world time")
.fallback(true)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.hide_effects = Setting.Bool.builder()
.name("hide-effects")
.comment("hide effect icons on top right corner")
.fallback(false)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java
index 6928e31..8a36bfe 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java
@@ -15,9 +15,9 @@ import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class PlayerList extends HudModule implements ICommons {
-
- public PlayerList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("PlayerList", builder, dispatcher);
+ @Override
+ public String getName() {
+ return "PlayerList";
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
index ecd1206..413f335 100644
--- a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
+++ b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
@@ -1,12 +1,9 @@
package ftbsc.bscv.modules.motion;
import com.mojang.brigadier.CommandDispatcher;
-import com.mojang.brigadier.arguments.BoolArgumentType;
-import com.mojang.brigadier.arguments.DoubleArgumentType;
-
import ftbsc.bscv.ICommons;
import ftbsc.bscv.events.BoatEvent;
-import ftbsc.bscv.modules.Module;
+import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Keyboard;
import ftbsc.bscv.tools.Setting;
import net.minecraft.command.CommandSource;
@@ -17,7 +14,17 @@ import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class BoatFly extends Module implements ICommons {
+public class BoatFly extends AbstractModule implements ICommons {
+
+ @Override
+ public String getName() {
+ return "BoatFly";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.MOTION;
+ }
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Double> rise;
@@ -26,45 +33,45 @@ public class BoatFly extends Module implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> sprint;
public final ForgeConfigSpec.ConfigValue<Boolean> drift;
- public BoatFly(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("BoatFly", Group.MOTION, builder, dispatcher);
+ public BoatFly() {
+ super();
this.speed = Setting.Decimal.builder()
.fallback(1.)
.name("speed")
.comment("magnitude of boat movement")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.rise = Setting.Decimal.builder()
.min(0.)
.fallback(0.5)
.name("rise")
.comment("vertical speed")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.gravity = Setting.Bool.builder()
.fallback(true)
.name("gravity")
.comment("toggle boat gravity")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.rotation = Setting.Bool.builder()
.fallback(true)
.name("rotation")
.comment("rotate boat with player")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.sprint = Setting.Bool.builder()
.fallback(true)
.name("sprint")
.comment("halve boat speed while not sprinting")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.drift = Setting.Bool.builder()
.fallback(false)
.name("drift")
.comment("allow boat drifting")
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
index 7938601..9193934 100644
--- a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
+++ b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
@@ -16,6 +16,20 @@ import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class VanillaFlight extends QuickModule implements ICommons {
+ @Override
+ public String getName() {
+ return "VanillaFlight";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.MOTION;
+ }
+
+ @Override
+ protected int getDefaultKey() {
+ return UNBOUND;
+ }
public final ForgeConfigSpec.ConfigValue<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Double> speed;
@@ -25,34 +39,34 @@ public class VanillaFlight extends QuickModule implements ICommons {
private int tick = 0;
- public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("VanillaFlight", Group.MOTION, UNBOUND, builder, dispatcher);
+ public VanillaFlight() {
+ super();
this.force = Setting.Bool.builder()
.name("force")
.comment("force enable flight on user")
.fallback(false)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.speed = Setting.Decimal.builder()
.min(0.)
.fallback(0.05)
.name("speed")
.comment("flight speed to set")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.antikick = Setting.Bool.builder()
.fallback(false)
.name("antikick")
.comment("prevent vanilla flight kick by descending")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.antikick_magnitude = Setting.Decimal.builder()
.min(0.)
.fallback(1.)
.name("magnitude")
.comment("magnitude of antikick push")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.antikick_cycle = Setting.Number.builder()
.min(0)
@@ -60,7 +74,7 @@ public class VanillaFlight extends QuickModule implements ICommons {
.fallback(0)
.name("cycle")
.comment("how often to run antikick routine")
- .build(this.name, builder, dispatcher);
+ .build(this);
}
private boolean couldFlyBefore = false;
diff --git a/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java b/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java
index f511e1e..7f69197 100644
--- a/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java
+++ b/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java
@@ -1,37 +1,43 @@
package ftbsc.bscv.modules.self;
-import com.mojang.brigadier.CommandDispatcher;
-
import ftbsc.bscv.ICommons;
import ftbsc.bscv.events.PacketEvent;
-import ftbsc.bscv.modules.Module;
+import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Setting;
-import net.minecraft.command.CommandSource;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CPlayerPacket;
import net.minecraft.network.play.client.CEntityActionPacket.Action;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class AntiHunger extends Module implements ICommons {
+public class AntiHunger extends AbstractModule implements ICommons {
+ @Override
+ public String getName() {
+ return "AntiHunger";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
+ }
public final ForgeConfigSpec.ConfigValue<Boolean> sprint;
public final ForgeConfigSpec.ConfigValue<Boolean> hover;
- public AntiHunger(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("AntiHunger", Group.SELF, builder, dispatcher);
+ public AntiHunger() {
+ super();
this.sprint = Setting.Bool.builder()
.fallback(true)
.name("sprint")
.comment("mask sprint toggle packets")
- .build(this.name, builder, dispatcher);
+ .build(this);
this.hover = Setting.Bool.builder()
.name("hover")
.comment("mark as not on-ground while walking")
.fallback(true)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java b/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java
index 81b9f66..0ad492e 100644
--- a/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java
+++ b/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java
@@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.events.PacketEvent;
-import ftbsc.bscv.modules.Module;
+import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Setting;
import net.minecraft.command.CommandSource;
import net.minecraft.network.play.server.SDisconnectPacket;
@@ -13,18 +13,28 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class AutoDisconnect extends Module implements ICommons {
+public class AutoDisconnect extends AbstractModule implements ICommons {
+
+ @Override
+ public String getName() {
+ return "AutoDisconnect";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
+ }
public final ForgeConfigSpec.ConfigValue<Double> threshold;
- public AutoDisconnect(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("AutoDisconnect", Group.SELF, builder, dispatcher);
+ public AutoDisconnect() {
+ super();
this.threshold = Setting.Decimal.builder()
.fallback(10.)
.name("threshold")
.comment("hp below which connection should be closed")
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
index 900cbd0..e275c4c 100644
--- a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
+++ b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
@@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.events.PacketEvent;
-import ftbsc.bscv.modules.Module;
+import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Setting;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
@@ -14,26 +14,36 @@ import net.minecraft.util.SoundEvents;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class AutoFish extends Module implements ICommons {
+public class AutoFish extends AbstractModule implements ICommons {
+
+ @Override
+ public String getName() {
+ return "AutoFish";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
+ }
public final ForgeConfigSpec.ConfigValue<Boolean> recast;
public final ForgeConfigSpec.ConfigValue<Integer> delay;
// public final ForgeConfigSpec.ConfigValue<Long> reaction;
- public AutoFish(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("AutoFish", Group.SELF, builder, dispatcher);
+ public AutoFish() {
+ super();
this.recast = Setting.Bool.builder()
.name("recast")
.comment("automatically recast hook after fishing")
.fallback(false)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.delay = Setting.Number.builder()
.fallback(2500)
.name("delay")
.comment("how long in ms to wait before recasting hook")
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoTool.java b/src/main/java/ftbsc/bscv/modules/self/AutoTool.java
index 3f0c2ab..2201343 100644
--- a/src/main/java/ftbsc/bscv/modules/self/AutoTool.java
+++ b/src/main/java/ftbsc/bscv/modules/self/AutoTool.java
@@ -2,14 +2,11 @@ package ftbsc.bscv.modules.self;
import java.util.List;
-import com.mojang.brigadier.CommandDispatcher;
-
import ftbsc.bscv.ICommons;
-import ftbsc.bscv.modules.Module;
+import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Inventory;
import ftbsc.bscv.tools.Setting;
import net.minecraft.block.BlockState;
-import net.minecraft.command.CommandSource;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockRayTraceResult;
@@ -17,18 +14,28 @@ import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class AutoTool extends Module implements ICommons {
+public class AutoTool extends AbstractModule implements ICommons {
+
+ @Override
+ public String getName() {
+ return "AutoTool";
+ }
+
+ @Override
+ public AbstractModule.Group getGroup() {
+ return AbstractModule.Group.SELF;
+ }
public final ForgeConfigSpec.ConfigValue<Integer> limit;
- public AutoTool(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("AutoTool", Group.SELF, builder, dispatcher);
+ public AutoTool() {
+ super();
this.limit = Setting.Number.builder()
.name("limit")
.comment("durability limit for tools, set to 0 to destroy them")
.fallback(1)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
private boolean itemIsTooDamaged(ItemStack item) {
diff --git a/src/main/java/ftbsc/bscv/modules/self/FastInteract.java b/src/main/java/ftbsc/bscv/modules/self/FastInteract.java
index f735c9d..e947b5e 100644
--- a/src/main/java/ftbsc/bscv/modules/self/FastInteract.java
+++ b/src/main/java/ftbsc/bscv/modules/self/FastInteract.java
@@ -15,14 +15,24 @@ import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.ICommons;
public class FastInteract extends QuickModule implements ICommons {
+ @Override
+ public String getName() {
+ return "FastInteract";
+ }
- Field delayField;
-
- public FastInteract(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("FastInteract", Group.SELF, UNBOUND, builder, dispatcher);
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
}
@Override
+ protected int getDefaultKey() {
+ return UNBOUND;
+ }
+
+ Field delayField;
+
+ @Override
protected void onEnabled() {
try {
delayField = MC.getClass().getDeclaredField("field_71467_ac");
diff --git a/src/main/java/ftbsc/bscv/modules/self/Freecam.java b/src/main/java/ftbsc/bscv/modules/self/Freecam.java
index fd22d9d..a80e5b3 100644
--- a/src/main/java/ftbsc/bscv/modules/self/Freecam.java
+++ b/src/main/java/ftbsc/bscv/modules/self/Freecam.java
@@ -29,26 +29,41 @@ public class Freecam extends QuickModule implements ICommons {
private GameType prev_gamemode = GameType.SURVIVAL;
private MockPlayer mock_player;
- public Freecam(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("Freecam", Group.SELF, UNBOUND, builder, dispatcher);
+ @Override
+ public String getName() {
+ return "Freecam";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
+ }
+
+ @Override
+ protected int getDefaultKey() {
+ return UNBOUND;
+ }
+
+ public Freecam() {
+ super();
this.log = Setting.Bool.builder()
.name("log")
.comment("log canceled packets")
.fallback(false)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.speed = Setting.Decimal.builder()
.name("speed")
.comment("flight speed in freecam")
.fallback(0.05)
- .build(this.name, builder, dispatcher);
+ .build(this);
this.drift = Setting.Bool.builder()
.name("drift")
.comment("allow inertia drift in freecam")
.fallback(true)
- .build(this.name, builder, dispatcher);
+ .build(this);
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/self/PortalGui.java b/src/main/java/ftbsc/bscv/modules/self/PortalGui.java
index 84c5d57..326f64d 100644
--- a/src/main/java/ftbsc/bscv/modules/self/PortalGui.java
+++ b/src/main/java/ftbsc/bscv/modules/self/PortalGui.java
@@ -1,18 +1,20 @@
package ftbsc.bscv.modules.self;
-import com.mojang.brigadier.CommandDispatcher;
-
import ftbsc.bscv.ICommons;
-import ftbsc.bscv.modules.Module;
-import net.minecraft.command.CommandSource;
-import net.minecraftforge.common.ForgeConfigSpec;
+import ftbsc.bscv.modules.AbstractModule;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class PortalGui extends Module implements ICommons {
+public class PortalGui extends AbstractModule implements ICommons {
+
+ @Override
+ public String getName() {
+ return "PortalGui";
+ }
- public PortalGui(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("PortalGui", Group.SELF, builder, dispatcher);
+ @Override
+ public Group getGroup() {
+ return Group.SELF;
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java b/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java
index 69d800d..4585a68 100644
--- a/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java
+++ b/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java
@@ -1,23 +1,29 @@
package ftbsc.bscv.modules.vision;
-import java.awt.event.KeyEvent;
-
-import com.mojang.brigadier.CommandDispatcher;
-
-import net.minecraft.command.CommandSource;
+import ftbsc.bscv.ICommons;
+import ftbsc.bscv.modules.QuickModule;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
-import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-import ftbsc.bscv.modules.QuickModule;
-import ftbsc.bscv.ICommons;
+import java.awt.event.KeyEvent;
public class Fullbright extends QuickModule implements ICommons {
-
- public Fullbright(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- super("Fullbright", Group.VISION, KeyEvent.VK_V, builder, dispatcher);
+
+ @Override
+ public String getName() {
+ return "Fullbright";
+ }
+
+ @Override
+ public Group getGroup() {
+ return Group.VISION;
+ }
+
+ @Override
+ protected int getDefaultKey() {
+ return KeyEvent.VK_V;
}
@SubscribeEvent
diff --git a/src/main/java/ftbsc/bscv/system/ModManager.java b/src/main/java/ftbsc/bscv/system/ModManager.java
new file mode 100644
index 0000000..ea64b0c
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/system/ModManager.java
@@ -0,0 +1,42 @@
+package ftbsc.bscv.system;
+
+import com.mojang.brigadier.CommandDispatcher;
+import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.api.IModule;
+import ftbsc.bscv.modules.AbstractModule;
+import ftbsc.bscv.modules.defense.Aura;
+import ftbsc.bscv.modules.hud.*;
+import ftbsc.bscv.modules.motion.BoatFly;
+import ftbsc.bscv.modules.motion.VanillaFlight;
+import ftbsc.bscv.modules.self.*;
+import ftbsc.bscv.modules.vision.Fullbright;
+import net.minecraft.command.CommandSource;
+import net.minecraftforge.common.ForgeConfigSpec;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class ModManager {
+ private final ForgeConfigSpec.Builder cfgBuilder;
+ private final CommandDispatcher<CommandSource> dispatcher;
+
+ public final Set<IModule<? extends Enum<?>> > mods;
+
+ public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) {
+ this.cfgBuilder = cfgBuilder;
+ this.dispatcher = dispatcher;
+ this.mods = new HashSet<>();
+ }
+
+ public void registerMod(IModule<? extends Enum<?>> mod) {
+ this.mods.add(mod);
+ }
+
+ public ForgeConfigSpec.Builder getCfgBuilder() {
+ return cfgBuilder;
+ }
+
+ public CommandDispatcher<CommandSource> getDispatcher() {
+ return dispatcher;
+ }
+}
diff --git a/src/main/java/ftbsc/bscv/tools/Setting.java b/src/main/java/ftbsc/bscv/tools/Setting.java
index 21f5501..7db1449 100644
--- a/src/main/java/ftbsc/bscv/tools/Setting.java
+++ b/src/main/java/ftbsc/bscv/tools/Setting.java
@@ -11,6 +11,7 @@ import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
+import ftbsc.bscv.api.IModule;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -50,11 +51,11 @@ public abstract class Setting<T> {
abstract Class<T> clazz();
- public ForgeConfigSpec.ConfigValue<T> build(String scope, ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
- ForgeConfigSpec.ConfigValue<T> conf = this.value(builder);
+ public ForgeConfigSpec.ConfigValue<T> build(IModule<?> module) {
+ ForgeConfigSpec.ConfigValue<T> conf = this.value(module.getConfigBuilder());
- dispatcher.register(
- Commands.literal(scope.toLowerCase())
+ module.getDispatcher().register(
+ Commands.literal(module.getName().toLowerCase())
.then(
Commands.literal(this.name.get())
.then(