How can I fly in any direction?

Avatar

By LaVacheMilka 16 March 2019 23:58

Member · 111 comments

var scriptName = "Vanilla Fly";
var scriptAuthor = "Senk Ju";
var scriptVersion = 1.0;

var speed = 2;

Math.radians = function (degrees) {
    return degrees * Math.PI / 180;
};

Math.degrees = function (radians) {
    return radians * 180 / Math.PI;
};

function FlyModule() {

    this.getName = function () {
        return "VanillaFly";
    }

    this.getDescription = function () {
        return "Vanilla Fly example."
    }

    this.getCategory = function () {
        return "Movement";
    }

    this.onUpdate = function () {
        mc.thePlayer.motionZ = 0;
        mc.thePlayer.motionY = 0;
        mc.thePlayer.motionX = 0;

        if (mc.gameSettings.keyBindForward.isKeyDown()) {

            var yaw = Math.radians(mc.thePlayer.rotationYaw);

            mc.thePlayer.motionX = -Math.sin(yaw) * speed;
            mc.thePlayer.motionZ = Math.cos(yaw) * speed;
        }
    }
}

var flyModule = new FlyModule();
var flyModuleClient;

function onEnable() {
    flyModuleClient = moduleManager.registerModule(flyModule);
}

function onDisable() {
    moduleManager.unregisterModule(flyModuleClient);
}

How can I fly in any direction?