feat: vanillaflight packet antikick, broken tho
This commit is contained in:
parent
82b57f4de9
commit
97129ddcef
1 changed files with 20 additions and 16 deletions
|
@ -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() && 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);
|
||||
}
|
||||
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++;
|
||||
}
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue