feat: added speed control to vanilla flight
This commit is contained in:
parent
963c67aeae
commit
f03ba40760
2 changed files with 34 additions and 6 deletions
|
@ -25,14 +25,14 @@ public class QuickModule extends Module {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKeyPress(InputEvent.KeyInputEvent event) {
|
public void onKeyPress(InputEvent.KeyInputEvent event) {
|
||||||
if (this.key.isDown()) {
|
if (this.key.isDown()) {
|
||||||
this.mod.toggle();
|
this.mod.toggle(); // TODO debounce this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKeyPress(InputEvent.MouseInputEvent event) {
|
public void onKeyPress(InputEvent.MouseInputEvent event) {
|
||||||
if (this.key.isDown()) {
|
if (this.key.isDown()) {
|
||||||
this.mod.toggle();
|
this.mod.toggle(); // TODO debounce this
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package co.fantabos.bscv.module.motion;
|
package co.fantabos.bscv.module.motion;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
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.BoSCoVicino;
|
||||||
import co.fantabos.bscv.module.QuickModule;
|
import co.fantabos.bscv.module.QuickModule;
|
||||||
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -12,19 +16,37 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
public class VanillaFlight extends QuickModule {
|
public class VanillaFlight extends QuickModule {
|
||||||
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> force;
|
public final ForgeConfigSpec.ConfigValue<Boolean> force;
|
||||||
|
public final ForgeConfigSpec.ConfigValue<Double> speed;
|
||||||
|
|
||||||
public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
||||||
super("VanillaFlight", Group.MOTION, -1, builder, 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 boolean couldFlyBefore = false;
|
||||||
|
private float flyingSpeedBefore = 0.05f;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTick(TickEvent.ClientTickEvent event) {
|
public void onTick(TickEvent.ClientTickEvent event) {
|
||||||
if (BoSCoVicino.minecraft.player != null) {
|
ClientPlayerEntity player = BoSCoVicino.minecraft.player;
|
||||||
BoSCoVicino.minecraft.player.abilities.mayfly = true;
|
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() {
|
protected void onEnabled() {
|
||||||
if (BoSCoVicino.minecraft.player != null) {
|
if (BoSCoVicino.minecraft.player != null) {
|
||||||
this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly;
|
this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly;
|
||||||
|
this.flyingSpeedBefore = BoSCoVicino.minecraft.player.abilities.getFlyingSpeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDisabled() {
|
protected void onDisabled() {
|
||||||
if (BoSCoVicino.minecraft.player != null) {
|
ClientPlayerEntity player = BoSCoVicino.minecraft.player;
|
||||||
BoSCoVicino.minecraft.player.abilities.mayfly = this.couldFlyBefore;
|
if (player != null) {
|
||||||
|
player.abilities.mayfly = this.couldFlyBefore;
|
||||||
|
player.abilities.setFlyingSpeed(this.flyingSpeedBefore);
|
||||||
|
if (this.force.get()) {
|
||||||
|
player.abilities.flying = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue