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!
This commit is contained in:
əlemi 2023-01-31 23:09:46 +01:00
parent c10c695e90
commit 80b08eb4d4
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
3 changed files with 63 additions and 4 deletions

View file

@ -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) {

View file

@ -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<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Boolean> antikick;
public final ForgeConfigSpec.ConfigValue<Double> antikick_magnitude;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle;
private final float minDescent = 0.03125f;
private final int maxTicks = 80;
private int tick = 0;
public VanillaFlight(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> 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));
}
}

View file

@ -19,7 +19,7 @@ public class FastInteract extends QuickModule {
Field delayField;
public FastInteract(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("FastInteract", Group.SELF, -1, builder, dispatcher);
super("FastInteract", Group.SELF, UNBOUND, builder, dispatcher);
}
@Override