public class BoatFly extends Module {
private static final double diagonal = 1 / Math.sqrt(2);
NumberSetting.Float speed = new NumberSetting.Float("speed", 10, 0, 50, 1);
NumberSetting.Float verticalSpeed = new NumberSetting.Float("vertical-speed", 6, 0, 20, 1);
NumberSetting.Float fallSpeed = new NumberSetting.Float("fall-speed", 0.1f, 0, 20, 1);
BooleanSetting phase = new BooleanSetting("phase", false);
BooleanSetting antiAFK = new BooleanSetting("anti-afk", true);
BooleanSetting automount = new BooleanSetting("automount", false);
BooleanSetting boost = new BooleanSetting("boost", false);
BoatEntity boat;
boolean dismount = false;
public BoatFly() {
super("BoatFly", 0, false, Category.MOVEMENT);
this.addSettings(speed, verticalSpeed, fallSpeed, phase, antiAFK, automount, boost);
this.setInstance();
}
private static BoatFly INSTANCE = new BoatFly();
public static BoatFly getInstance() {
if (INSTANCE == null) {
INSTANCE = new BoatFly();
}
return INSTANCE;
}
private void setInstance() {
INSTANCE = this;
}
@Override
public void onDisable() {
super.onDisable();
boat = null;
}
@Override
public void onTick() {
super.onTick();
if (dismount) {
NotificationManager.notif("mount");
mc.player.setPosition(boat.getPos().add(0,0.75,0));
mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(boat.getPos().add(0,0.75,0).x, boat.getPos().add(0,0.75,0).y, boat.getPos().add(0,0.75,0).z, false));
mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(mc.player.getYaw(), mc.player.getPitch(), false));
mc.interactionManager.interactEntity(mc.player, boat, Hand.MAIN_HAND);
dismount = false;
}
}
@Subscribe
private void onDismount(DismountEvent.Post event) {
if (boat != null) {
dismount = true;
}
}
@Subscribe
private void onBoatMove(BoatMoveEvent event) {
event.getBoat().noClip = false;
if (event.getBoat().getControllingPassenger() != mc.player) return;
if (phase.isEnabled()) event.getBoat().noClip = true;
boat = event.getBoat();
if (boost.isEnabled()) {
mc.player.swingHand(Hand.MAIN_HAND);
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING));
mc.interactionManager.attackEntity(mc.player, boat);
}
event.getBoat().setYaw(mc.player.getYaw());
Vec3d vel = getHorizontalVelocity(speed.getValue());
double velX = vel.getX();
double velY = 0;
if (antiAFK.isEnabled()) {
if (mc.player.age % 2 == 0) {
velY = 0.4;
} else velY = -0.4;
}
double velZ = vel.getZ();
if (mc.options.jumpKey.isPressed()) velY += verticalSpeed.getValue() / 20;
if (mc.options.sneakKey.isPressed()) velY -= verticalSpeed.getValue() / 20;
else velY -= fallSpeed.getValue() / 20;
event.getBoat().setVelocity(velX, velY, velZ);
}
public static Vec3d getHorizontalVelocity(double bps) {
Vec3d horizontalVelocity;
float yaw = mc.player.getYaw();
Vec3d forward = Vec3d.fromPolar(0, yaw);
Vec3d right = Vec3d.fromPolar(0, yaw + 90);
double velX = 0;
double velZ = 0;
boolean a = false;
if (mc.player.input.pressingForward) {
velX += forward.x / 20 * bps;
velZ += forward.z / 20 * bps;
a = true;
}
if (mc.player.input.pressingBack) {
velX -= forward.x / 20 * bps;
velZ -= forward.z / 20 * bps;
a = true;
}
boolean b = false;
if (mc.player.input.pressingRight) {
velX += right.x / 20 * bps;
velZ += right.z / 20 * bps;
b = true;
}
if (mc.player.input.pressingLeft) {
velX -= right.x / 20 * bps;
velZ -= right.z / 20 * bps;
b = true;
}
if (a && b) {
velX *= diagonal;
velZ *= diagonal;
}
horizontalVelocity = new Vec3d(velX, 0, velZ);
return horizontalVelocity;
}
}