diff options
Diffstat (limited to 'src/main')
13 files changed, 216 insertions, 278 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/HudModule.java b/src/main/java/ftbsc/bscv/modules/HudModule.java index 773560a..8c559fb 100644 --- a/src/main/java/ftbsc/bscv/modules/HudModule.java +++ b/src/main/java/ftbsc/bscv/modules/HudModule.java @@ -1,47 +1,53 @@ package ftbsc.bscv.modules; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.DoubleArgumentType; -import com.mojang.brigadier.arguments.IntegerArgumentType; +import ftbsc.bscv.ICommons; import ftbsc.bscv.tools.Anchor; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.server.command.EnumArgument; public abstract class HudModule extends Module { public final ForgeConfigSpec.ConfigValue<Integer> x; public final ForgeConfigSpec.ConfigValue<Integer> y; public final ForgeConfigSpec.ConfigValue<Double> scale; - public final ForgeConfigSpec.EnumValue<Anchor> anchor; + public final ForgeConfigSpec.ConfigValue<Anchor> anchor; protected HudModule(String name, ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super(name, Group.HUD, builder, dispatcher); - this.x = this.option( - "x", "horizontal offset", 0, - IntegerArgumentType.integer(0), Integer.class, - builder, dispatcher - ); - - this.y = this.option( - "y", "vertical offset", 0, - IntegerArgumentType.integer(0), Integer.class, - builder, dispatcher - ); - - this.scale = this.option( - "scale", "scale of element", 1.0, - DoubleArgumentType.doubleArg(0.0), Double.class, - builder, dispatcher - ); - - this.anchor = this.optionEnum( - "anchor", "origin point for coordinates", Anchor.TOPLEFT, - EnumArgument.enumArgument(Anchor.class), Anchor.class, - builder, dispatcher - ); + this.x = Setting.Number.builder() + .name("x") + .comment("horizontal offset") + .fallback(0) + .build(builder, dispatcher); + + this.y = Setting.Number.builder() + .name("y") + .comment("vertical offset") + .fallback(0) + .build(builder, dispatcher); + + this.scale = Setting.Decimal.builder() + .name("scale") + .comment("scale of element") + .fallback(1.0) + .build(builder, dispatcher); + + this.anchor = Setting.Switch.builder(Anchor.class) + .name("anchor") + .comment("origin point for coordinates") + .fallback(Anchor.TOPLEFT) + .build(builder, dispatcher); } + protected boolean shouldHide() { + if (ICommons.MC.options.renderDebug) { + return true; + } + + return false; + } } diff --git a/src/main/java/ftbsc/bscv/modules/Module.java b/src/main/java/ftbsc/bscv/modules/Module.java index 3cdc50a..57a5a00 100644 --- a/src/main/java/ftbsc/bscv/modules/Module.java +++ b/src/main/java/ftbsc/bscv/modules/Module.java @@ -56,81 +56,6 @@ public abstract class Module { return this; } - - // TODO can I merge these two option into one? Maybe redo with builder pattern? - - public <T extends Enum<T>> ForgeConfigSpec.EnumValue<T> optionEnum( - String name, - String comment, - T fallback, - ArgumentType<T> argument, - Class<T> clazz, - ForgeConfigSpec.Builder builder, - CommandDispatcher<CommandSource> dispatcher - ) { - ForgeConfigSpec.EnumValue<T> conf = builder - .comment(comment) - .defineEnum(name, fallback); - - dispatcher.register( - Commands.literal(this.name.toLowerCase()) - .then( - Commands.literal(name) - .then( - Commands.argument(name, argument) - .executes( ctx -> { - T value = ctx.getArgument(name, clazz); - conf.set(value); - conf.save(); - log(String.format("> %s -> %s <", String.join(".", conf.getPath()), conf.get().toString())); - return 1; - })) - .executes(ctx -> { - log(String.format("> %s: %s <", String.join(".", conf.getPath()), conf.get().toString())); - return 1; - }) - ) - ); - - return conf; - } - - public <T> ForgeConfigSpec.ConfigValue<T> option( - String name, - String comment, - T fallback, - ArgumentType<T> argument, - Class<T> clazz, - ForgeConfigSpec.Builder builder, - CommandDispatcher<CommandSource> dispatcher - ) { - ForgeConfigSpec.ConfigValue<T> conf = builder - .comment(comment) - .define(name, fallback); - - dispatcher.register( - Commands.literal(this.name.toLowerCase()) - .then( - Commands.literal(name) - .then( - Commands.argument(name, argument) - .executes( ctx -> { - T value = ctx.getArgument(name, clazz); - conf.set(value); - conf.save(); - log(String.format("> %s -> %s <", String.join(".", conf.getPath()), conf.get().toString())); - return 1; - })) - .executes(ctx -> { - log(String.format("> %s: %s <", name, conf.get().toString())); - return 1; - }) - ) - ); - - return conf; - } - protected void onEnabled() {} protected void onDisabled() {} diff --git a/src/main/java/ftbsc/bscv/modules/defense/Aura.java b/src/main/java/ftbsc/bscv/modules/defense/Aura.java index 813b3ef..4ed4850 100644 --- a/src/main/java/ftbsc/bscv/modules/defense/Aura.java +++ b/src/main/java/ftbsc/bscv/modules/defense/Aura.java @@ -5,6 +5,7 @@ import com.mojang.brigadier.arguments.DoubleArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.QuickModule; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -21,17 +22,20 @@ public class Aura extends QuickModule implements ICommons { 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 - ); + this.reach = Setting.Decimal.builder() + .min(0.) + .fallback(5.) + .name("reach") + .comment("aura attack reach") + .build(builder, dispatcher); + + this.strenght = Setting.Decimal.builder() + .min(0.) + .max(1.) + .name("strenght") + .comment("minimum strenght required for attack") + .fallback(1.) + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java index c48b546..b3386fc 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java +++ b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java @@ -8,10 +8,10 @@ import java.util.List; import java.util.stream.Collectors; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.StringArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.HudModule; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.util.text.Color; @@ -29,11 +29,11 @@ public class EntityList extends HudModule implements ICommons { public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("EntityList", builder, dispatcher); - this.search = this.option( - "search", "highlight names containing this text", "", - StringArgumentType.string(), String.class, - builder, dispatcher - ); + this.search = Setting.Str.builder() + .name("search") + .comment("highlight names containing this text") + .fallback("") + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java index 95e3231..7a610a3 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java +++ b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java @@ -5,10 +5,10 @@ import static ftbsc.bscv.tools.Text.TextBuilder; import java.util.ArrayDeque; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.HudModule; +import ftbsc.bscv.tools.Setting; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandSource; import net.minecraft.util.math.vector.Vector3d; @@ -47,29 +47,29 @@ public class InfoDisplay extends HudModule implements ICommons { public InfoDisplay(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("InfoDisplay", builder, dispatcher); - this.logo = this.option( - "logo", "show logo at top of list", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.speed = this.option( - "speed", "show speed meter", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.time = this.option( - "time", "show world time", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.hide_effects = this.option( - "hide-effects", "hide effect icons on top right corner", false, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); + this.logo = Setting.Bool.builder() + .name("logo") + .comment("show logo at top of list") + .fallback(true) + .build(builder, dispatcher); + + this.speed = Setting.Bool.builder() + .name("speed") + .comment("show speed meter") + .fallback(true) + .build(builder, dispatcher); + + this.time = Setting.Bool.builder() + .name("time") + .comment("show world time") + .fallback(true) + .build(builder, dispatcher); + + this.hide_effects = Setting.Bool.builder() + .name("hide-effects") + .comment("hide effect icons on top right corner") + .fallback(false) + .build(builder, dispatcher); } @SubscribeEvent @@ -96,14 +96,14 @@ public class InfoDisplay extends HudModule implements ICommons { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { if (event.getType() == ElementType.POTION_ICONS) { - if (this.hide_effects.get()) { + if (this.hide_effects.get() && event.isCancelable()) { event.setCanceled(true); } } if (event.getType() != ElementType.TEXT) return; + if (this.shouldHide()) return; - Minecraft mc = MC; int offset = 0; double scale = this.scale.get(); if (this.logo.get()) { @@ -115,13 +115,13 @@ public class InfoDisplay extends HudModule implements ICommons { .style(Style.EMPTY.withColor(Color.fromRgb(12542314)).withBold(true)) .scale(scale * 4.0) .render(event.getMatrixStack(), event.getWindow()); - offset += mc.font.lineHeight * scale * 4.0; + offset += MC.font.lineHeight * scale * 4.0; } if (this.time.get()) { long daytime = 0; - if (mc.level != null) { - daytime = mc.level.dayTime(); + if (MC.level != null) { + daytime = MC.level.dayTime(); } TextBuilder() .txt(String.format("> time: %d/1200 (%d day)", (daytime / 20) % 1200, daytime / (20 * 1200) )) @@ -130,7 +130,7 @@ public class InfoDisplay extends HudModule implements ICommons { .y(this.y.get() + offset) .scale(scale) .render(event.getMatrixStack(), event.getWindow()); - offset += mc.font.lineHeight * scale; + offset += MC.font.lineHeight * scale; } if (this.speed.get()) { @@ -141,7 +141,7 @@ public class InfoDisplay extends HudModule implements ICommons { .y(this.y.get() + offset) .scale(scale) .render(event.getMatrixStack(), event.getWindow()); - offset += mc.font.lineHeight * scale; + offset += MC.font.lineHeight * scale; } } } diff --git a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java index deb6644..6597611 100644 --- a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java +++ b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java @@ -8,10 +8,10 @@ import ftbsc.bscv.ICommons; import ftbsc.bscv.events.BoatEvent; import ftbsc.bscv.modules.Module; import ftbsc.bscv.tools.Keyboard; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; -import net.minecraft.util.math.vector.Vector2f; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.Phase; @@ -22,27 +22,49 @@ public class BoatFly extends Module implements ICommons { public final ForgeConfigSpec.ConfigValue<Double> speed; public final ForgeConfigSpec.ConfigValue<Double> rise; public final ForgeConfigSpec.ConfigValue<Boolean> gravity; + public final ForgeConfigSpec.ConfigValue<Boolean> rotation; + 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); - this.speed = this.option( - "speed", "magnitude of boat movement", 1., - DoubleArgumentType.doubleArg(), Double.class, - builder, dispatcher - ); - - this.rise = this.option( - "rise", "vertical speed", 0.5, - DoubleArgumentType.doubleArg(), Double.class, - builder, dispatcher - ); - - this.gravity = this.option( - "gravity", "toggle boat gravity", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); + this.speed = Setting.Decimal.builder() + .fallback(1.) + .name("speed") + .comment("magnitude of boat movement") + .build(builder, dispatcher); + + this.rise = Setting.Decimal.builder() + .min(0.) + .fallback(0.5) + .name("rise") + .comment("vertical speed") + .build(builder, dispatcher); + + this.gravity = Setting.Bool.builder() + .fallback(true) + .name("gravity") + .comment("toggle boat gravity") + .build(builder, dispatcher); + + this.rotation = Setting.Bool.builder() + .fallback(true) + .name("rotation") + .comment("rotate boat with player") + .build(builder, dispatcher); + + this.sprint = Setting.Bool.builder() + .fallback(true) + .name("sprint") + .comment("halve boat speed while not sprinting") + .build(builder, dispatcher); + + this.drift = Setting.Bool.builder() + .fallback(false) + .name("drift") + .comment("allow boat drifting") + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java index 74dcb8f..425ba47 100644 --- a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java +++ b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java @@ -1,13 +1,11 @@ package ftbsc.bscv.modules.motion; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.arguments.DoubleArgumentType; -import com.mojang.brigadier.arguments.IntegerArgumentType; import ftbsc.bscv.BoSCoVicino; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.QuickModule; +import ftbsc.bscv.tools.Setting; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.command.CommandSource; import net.minecraft.network.play.client.CPlayerPacket; @@ -30,35 +28,39 @@ public class VanillaFlight extends QuickModule implements ICommons { public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("VanillaFlight", Group.MOTION, UNBOUND, builder, dispatcher); - this.force = this.option( - "force", "force enable flight on user", false, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.speed = this.option( - "speed", "flight speed to set", 0.05, - DoubleArgumentType.doubleArg(0.0), Double.class, - builder, dispatcher - ); - - this.antikick = this.option( - "antikick", "prevent vanilla flight kick by descending", false, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.antikick_magnitude = this.option( - "magnitude", "magnitude of antikick push", 1.0, - DoubleArgumentType.doubleArg(0.0), Double.class, - builder, dispatcher - ); - - this.antikick_cycle = this.option( - "cycle", "how often to run antikick routine", 0, - IntegerArgumentType.integer(0, 79), Integer.class, - builder, dispatcher - ); + this.force = Setting.Bool.builder() + .name("force") + .comment("force enable flight on user") + .fallback(false) + .build(builder, dispatcher); + + this.speed = Setting.Decimal.builder() + .min(0.) + .fallback(0.05) + .name("speed") + .comment("flight speed to set") + .build(builder, dispatcher); + + this.antikick = Setting.Bool.builder() + .fallback(false) + .name("antikick") + .comment("prevent vanilla flight kick by descending") + .build(builder, dispatcher); + + this.antikick_magnitude = Setting.Decimal.builder() + .min(0.) + .fallback(1.) + .name("magnitude") + .comment("magnitude of antikick push") + .build(builder, dispatcher); + + this.antikick_cycle = Setting.Number.builder() + .min(0) + .max(79) + .fallback(0) + .name("cycle") + .comment("how often to run antikick routine") + .build(builder, dispatcher); } 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 6630aa5..1978d6e 100644 --- a/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java +++ b/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java @@ -1,11 +1,11 @@ package ftbsc.bscv.modules.self; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.events.PacketEvent; import ftbsc.bscv.modules.Module; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraft.network.play.client.CEntityActionPacket; import net.minecraft.network.play.client.CPlayerPacket; @@ -21,17 +21,17 @@ public class AntiHunger extends Module implements ICommons { public AntiHunger(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("AntiHunger", Group.SELF, builder, dispatcher); - this.sprint = this.option( - "sprint", "mask sprint toggle packets", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.hover = this.option( - "hover", "mark as not on-ground while walking", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); + this.sprint = Setting.Bool.builder() + .fallback(true) + .name("sprint") + .comment("mask sprint toggle packets") + .build(builder, dispatcher); + + this.hover = Setting.Bool.builder() + .name("hover") + .comment("mark as not on-ground while walking") + .fallback(true) + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java b/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java index a192581..6010523 100644 --- a/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java +++ b/src/main/java/ftbsc/bscv/modules/self/AutoDisconnect.java @@ -1,11 +1,11 @@ package ftbsc.bscv.modules.self; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.DoubleArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.events.PacketEvent; import ftbsc.bscv.modules.Module; +import ftbsc.bscv.tools.Setting; import net.minecraft.command.CommandSource; import net.minecraft.network.play.server.SDisconnectPacket; import net.minecraft.network.play.server.SUpdateHealthPacket; @@ -20,11 +20,11 @@ public class AutoDisconnect extends Module implements ICommons { public AutoDisconnect(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("AutoDisconnect", Group.SELF, builder, dispatcher); - this.threshold = this.option( - "threshold", "hp below which connection should be closed", 10., - DoubleArgumentType.doubleArg(0., 20.), Double.class, - builder, dispatcher - ); + this.threshold = Setting.Decimal.builder() + .fallback(10.) + .name("threshold") + .comment("hp below which connection should be closed") + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java index 78bed18..9b8dbdc 100644 --- a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java +++ b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java @@ -1,12 +1,11 @@ package ftbsc.bscv.modules.self; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.arguments.LongArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.events.PacketEvent; import ftbsc.bscv.modules.Module; +import ftbsc.bscv.tools.Setting; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandSource; import net.minecraft.network.play.server.SPlaySoundEffectPacket; @@ -18,29 +17,23 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class AutoFish extends Module implements ICommons { public final ForgeConfigSpec.ConfigValue<Boolean> recast; - public final ForgeConfigSpec.ConfigValue<Long> delay; + 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); - this.recast = this.option( - "recast", "automatically recast hook after fishing", false, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); + this.recast = Setting.Bool.builder() + .name("recast") + .comment("automatically recast hook after fishing") + .fallback(false) + .build(builder, dispatcher); - this.delay = this.option( - "delay", "how long in ms to wait before recasting hook", 2500L, - LongArgumentType.longArg(0), Long.class, - builder, dispatcher - ); - - // this.reaction = this.option( - // "reaction", "time in ms to react to fish biting", 0L, - // LongArgumentType.longArg(0), Long.class, - // builder, dispatcher - // ); + this.delay = Setting.Number.builder() + .fallback(2500) + .name("delay") + .comment("how long in ms to wait before recasting hook") + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoTool.java b/src/main/java/ftbsc/bscv/modules/self/AutoTool.java index 2e26594..4abd8e7 100644 --- a/src/main/java/ftbsc/bscv/modules/self/AutoTool.java +++ b/src/main/java/ftbsc/bscv/modules/self/AutoTool.java @@ -3,11 +3,11 @@ package ftbsc.bscv.modules.self; import java.util.List; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.IntegerArgumentType; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.Module; 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; @@ -24,11 +24,11 @@ public class AutoTool extends Module implements ICommons { public AutoTool(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("AutoTool", Group.SELF, builder, dispatcher); - this.limit = this.option( - "limit", "durability limit for tools, set to 0 to destroy them", 1, - IntegerArgumentType.integer(0), Integer.class, - builder, dispatcher - ); + this.limit = Setting.Number.builder() + .name("limit") + .comment("durability limit for tools, set to 0 to destroy them") + .fallback(1) + .build(builder, dispatcher); } private boolean itemIsTooDamaged(ItemStack item) { diff --git a/src/main/java/ftbsc/bscv/modules/self/Freecam.java b/src/main/java/ftbsc/bscv/modules/self/Freecam.java index 72b64a4..78312d3 100644 --- a/src/main/java/ftbsc/bscv/modules/self/Freecam.java +++ b/src/main/java/ftbsc/bscv/modules/self/Freecam.java @@ -1,14 +1,13 @@ package ftbsc.bscv.modules.self; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.arguments.DoubleArgumentType; import ftbsc.bscv.BoSCoVicino; import ftbsc.bscv.events.PacketEvent; import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.QuickModule; import ftbsc.bscv.tools.Keyboard; +import ftbsc.bscv.tools.Setting; import net.minecraft.client.entity.player.RemoteClientPlayerEntity; import net.minecraft.client.network.play.NetworkPlayerInfo; import net.minecraft.command.CommandSource; @@ -33,23 +32,23 @@ public class Freecam extends QuickModule implements ICommons { public Freecam(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("Freecam", Group.SELF, UNBOUND, builder, dispatcher); - this.log = this.option( - "log", "log canceled packets", false, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); - - this.speed = this.option( - "speed", "flight speed in freecam", 0.05, - DoubleArgumentType.doubleArg(0.0), Double.class, - builder, dispatcher - ); - - this.drift = this.option( - "drift", "allow inertia drift in freecam", true, - BoolArgumentType.bool(), Boolean.class, - builder, dispatcher - ); + this.log = Setting.Bool.builder() + .name("log") + .comment("log canceled packets") + .fallback(false) + .build(builder, dispatcher); + + this.speed = Setting.Decimal.builder() + .name("speed") + .comment("flight speed in freecam") + .fallback(0.05) + .build(builder, dispatcher); + + this.drift = Setting.Bool.builder() + .name("drift") + .comment("allow inertia drift in freecam") + .fallback(true) + .build(builder, dispatcher); } @SubscribeEvent diff --git a/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java b/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java index 3e8942c..69d800d 100644 --- a/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java +++ b/src/main/java/ftbsc/bscv/modules/vision/Fullbright.java @@ -3,7 +3,6 @@ package ftbsc.bscv.modules.vision; import java.awt.event.KeyEvent; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.StringArgumentType; import net.minecraft.command.CommandSource; import net.minecraft.potion.Effect; @@ -17,31 +16,19 @@ import ftbsc.bscv.ICommons; public class Fullbright extends QuickModule implements ICommons { - private final ForgeConfigSpec.ConfigValue<String> mode; - public Fullbright(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("Fullbright", Group.VISION, KeyEvent.VK_V, builder, dispatcher); - - this.mode = this.option( - "mode", "either potion or potion", "potion", - StringArgumentType.string(), String.class, - builder, dispatcher - ); } @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (MC == null) return; if (MC.player == null) return; - if (this.mode.get().equals("potion")) { - MC.player.addEffect(new EffectInstance(Effect.byId(16), 5204)); - } + MC.player.addEffect(new EffectInstance(Effect.byId(16), 5204)); } @Override protected void onDisabled() { - if (this.mode.get().equals("potion")) { - MC.player.removeEffect(Effect.byId(16)); - } + MC.player.removeEffect(Effect.byId(16)); } } |