diff options
author | alemi <me@alemi.dev> | 2023-02-16 00:21:53 +0100 |
---|---|---|
committer | alemi <me@alemi.dev> | 2023-02-16 00:21:53 +0100 |
commit | 97129ddceff66d17f186d5b2c66feb129ebb2652 (patch) | |
tree | 6806f557ae81d877e9e908577e1fdaffd69fc942 /src/main/java | |
parent | 82b57f4de98710eea54a251779808d2c7304115c (diff) |
feat: vanillaflight packet antikick, broken tho
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java index ae00d3d..74dcb8f 100644 --- a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java +++ b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java @@ -10,8 +10,11 @@ import ftbsc.bscv.ICommons; import ftbsc.bscv.modules.QuickModule; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.command.CommandSource; +import net.minecraft.network.play.client.CPlayerPacket; +import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.eventbus.api.SubscribeEvent; public class VanillaFlight extends QuickModule implements ICommons { @@ -22,8 +25,6 @@ public class VanillaFlight extends QuickModule implements ICommons { 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) { @@ -65,29 +66,32 @@ public class VanillaFlight extends QuickModule implements ICommons { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { - ClientPlayerEntity player = MC.player; - if (player == null) return; + if (event.phase == Phase.END) return; + if (MC.player == null) return; - player.abilities.mayfly = true; - player.abilities.setFlyingSpeed(this.speed.get().floatValue()); + MC.player.abilities.mayfly = true; + MC.player.abilities.setFlyingSpeed(this.speed.get().floatValue()); if (this.force.get()) { - player.abilities.flying = true; + MC.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++; + if (this.antikick.get() && MC.player.abilities.flying) { + this.tick = ( this.tick + 1 ) % this.antikick_cycle.get(); + if (this.tick == 0) { + Vector3d pos = MC.player.position(); + BoSCoVicino.log("[*] antikick"); + MC.player.connection.send( + new CPlayerPacket.PositionPacket(pos.x, pos.y - this.antikick_magnitude.get(), pos.z, false) + ); + MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z); } + } else { + this.tick = 0; // reset antikick counter } } @Override protected void onEnabled() { + this.tick = 0; if (MC.player != null) { this.couldFlyBefore = MC.player.abilities.mayfly; this.flyingSpeedBefore = MC.player.abilities.getFlyingSpeed(); |