From 80b08eb4d4d076377222afcb856a5e76e26bf71c Mon Sep 17 00:00:00 2001 From: alemidev Date: Tue, 31 Jan 2023 23:09:46 +0100 Subject: chore: added value for unbound and some WIP code added a command stub for setting keybinds, but it's not really working or proper. something to finish eventually! --- .../java/co/fantabos/bscv/module/QuickModule.java | 23 ++++++++++++ .../fantabos/bscv/module/motion/VanillaFlight.java | 42 ++++++++++++++++++++-- .../co/fantabos/bscv/module/self/FastInteract.java | 2 +- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/main/java/co/fantabos/bscv/module/QuickModule.java b/src/main/java/co/fantabos/bscv/module/QuickModule.java index 470aa5e..b79d2bb 100644 --- a/src/main/java/co/fantabos/bscv/module/QuickModule.java +++ b/src/main/java/co/fantabos/bscv/module/QuickModule.java @@ -1,9 +1,12 @@ package co.fantabos.bscv.module; import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.StringArgumentType; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.util.InputMappings; import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.MinecraftForge; @@ -14,6 +17,8 @@ import co.fantabos.bscv.BoSCoVicino; // TODO rename public class QuickModule extends Module { + public static final int UNBOUND = InputMappings.UNKNOWN.getValue(); + private class ToggleHook { private final KeyBinding key; private final Module mod; @@ -55,6 +60,24 @@ public class QuickModule extends Module { // register a separate subclass on the hook, so that it's always listening MinecraftForge.EVENT_BUS.register(new ToggleHook(this.keybind, this)); + + // dispatcher.register( + // Commands.literal(this.name.toLowerCase()) + // .then( + // Commands.literal("bind") + // .then( + // Commands.argument("key", StringArgumentType.word()) + // .executes( ctx -> { + // this.keybind.setKey( + // InputMappings.getKey( // TODO it's not this easy! + // StringArgumentType.getString(ctx, "key") + // ) + // ); + // return 1; + // }) + // ) + // ) + // ); } private static String key_name(String name) { diff --git a/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java b/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java index 12afaf1..2c32a39 100644 --- a/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java +++ b/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java @@ -3,12 +3,12 @@ package co.fantabos.bscv.module.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 co.fantabos.bscv.BoSCoVicino; import co.fantabos.bscv.module.QuickModule; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.command.CommandSource; -import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -17,12 +17,19 @@ public class VanillaFlight extends QuickModule { public final ForgeConfigSpec.ConfigValue force; public final ForgeConfigSpec.ConfigValue speed; + public final ForgeConfigSpec.ConfigValue antikick; + public final ForgeConfigSpec.ConfigValue antikick_magnitude; + public final ForgeConfigSpec.ConfigValue antikick_cycle; + + private final float minDescent = 0.03125f; + private final int maxTicks = 80; + private int tick = 0; public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher dispatcher) { - super("VanillaFlight", Group.MOTION, -1, builder, dispatcher); + super("VanillaFlight", Group.MOTION, UNBOUND, builder, dispatcher); this.force = this.option( - "force", "force enable flight on user", true, + "force", "force enable flight on user", false, BoolArgumentType.bool(), Boolean.class, builder, dispatcher ); @@ -33,6 +40,23 @@ public class VanillaFlight extends QuickModule { 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 + ); } private boolean couldFlyBefore = false; @@ -48,6 +72,17 @@ public class VanillaFlight extends QuickModule { if (this.force.get()) { player.abilities.flying = true; } + if (this.antikick.get()) { + if (this.tick != 0 && this.tick % (maxTicks - this.antikick_cycle.get()) == 0) { + player.push(0.0, -(this.antikick_magnitude.get() * minDescent), 0.0); + this.tick = 0; + } else if (this.tick == 0) { + player.push(0.0, this.antikick_magnitude.get() * minDescent, 0.0); + this.tick++; + } else { + this.tick++; + } + } } @Override @@ -55,6 +90,7 @@ public class VanillaFlight extends QuickModule { if (BoSCoVicino.minecraft.player != null) { this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly; this.flyingSpeedBefore = BoSCoVicino.minecraft.player.abilities.getFlyingSpeed(); + BoSCoVicino.log(String.format("Flying speed before = %f", this.flyingSpeedBefore)); } } diff --git a/src/main/java/co/fantabos/bscv/module/self/FastInteract.java b/src/main/java/co/fantabos/bscv/module/self/FastInteract.java index 1227aab..eba065f 100644 --- a/src/main/java/co/fantabos/bscv/module/self/FastInteract.java +++ b/src/main/java/co/fantabos/bscv/module/self/FastInteract.java @@ -19,7 +19,7 @@ public class FastInteract extends QuickModule { Field delayField; public FastInteract(ForgeConfigSpec.Builder builder, CommandDispatcher dispatcher) { - super("FastInteract", Group.SELF, -1, builder, dispatcher); + super("FastInteract", Group.SELF, UNBOUND, builder, dispatcher); } @Override -- cgit v1.2.3-56-ga3b1