diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/co/fantabos/bscv/module/QuickModule.java | 4 | ||||
-rw-r--r-- | src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java | 36 |
2 files changed, 34 insertions, 6 deletions
diff --git a/src/main/java/co/fantabos/bscv/module/QuickModule.java b/src/main/java/co/fantabos/bscv/module/QuickModule.java index 4942476..b6a0be0 100644 --- a/src/main/java/co/fantabos/bscv/module/QuickModule.java +++ b/src/main/java/co/fantabos/bscv/module/QuickModule.java @@ -25,14 +25,14 @@ public class QuickModule extends Module { @SubscribeEvent public void onKeyPress(InputEvent.KeyInputEvent event) { if (this.key.isDown()) { - this.mod.toggle(); + this.mod.toggle(); // TODO debounce this } } @SubscribeEvent public void onKeyPress(InputEvent.MouseInputEvent event) { if (this.key.isDown()) { - this.mod.toggle(); + this.mod.toggle(); // TODO debounce this } } 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 2b20239..12afaf1 100644 --- a/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java +++ b/src/main/java/co/fantabos/bscv/module/motion/VanillaFlight.java @@ -1,10 +1,14 @@ package co.fantabos.bscv.module.motion; import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.DoubleArgumentType; 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; @@ -12,19 +16,37 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class VanillaFlight extends QuickModule { public final ForgeConfigSpec.ConfigValue<Boolean> force; + public final ForgeConfigSpec.ConfigValue<Double> speed; public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { super("VanillaFlight", Group.MOTION, -1, builder, dispatcher); + this.force = this.option( + "force", "force enable flight on user", true, + 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 + ); } private boolean couldFlyBefore = false; + private float flyingSpeedBefore = 0.05f; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { - if (BoSCoVicino.minecraft.player != null) { - BoSCoVicino.minecraft.player.abilities.mayfly = true; + ClientPlayerEntity player = BoSCoVicino.minecraft.player; + if (player == null) return; + + player.abilities.mayfly = true; + player.abilities.setFlyingSpeed(this.speed.get().floatValue()); + if (this.force.get()) { + player.abilities.flying = true; } } @@ -32,13 +54,19 @@ public class VanillaFlight extends QuickModule { protected void onEnabled() { if (BoSCoVicino.minecraft.player != null) { this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly; + this.flyingSpeedBefore = BoSCoVicino.minecraft.player.abilities.getFlyingSpeed(); } } @Override protected void onDisabled() { - if (BoSCoVicino.minecraft.player != null) { - BoSCoVicino.minecraft.player.abilities.mayfly = this.couldFlyBefore; + ClientPlayerEntity player = BoSCoVicino.minecraft.player; + if (player != null) { + player.abilities.mayfly = this.couldFlyBefore; + player.abilities.setFlyingSpeed(this.flyingSpeedBefore); + if (this.force.get()) { + player.abilities.flying = false; + } } } } |