[SCRIPT] .Rotation 1.0.0



  • .Rotation
    aliases: .rotate

    .Rotation allows you to rotate to any yaw and pitch with much difficulty.
    By using reference magic and avoiding the use of return in external functions, I have overengineered a simple script that would normally be accomplished in 10 lines.

    Syntax

    .rotation [get/set <yaw> <pitch>/setYaw <yaw>/setPitch <pitch>]
    

    Thanks for coming to my TED Talk. Here's the download bye.
    rotation.js

    /// api_version=2
    var script = registerScript({
        name: "Rotation",
        version: "1.0.0",
        authors: ["Qther"]
    });
    
    script.registerCommand({
        name: "Rotation",
        aliases: ["rotation", "rotate"]
    }, function (command) {
        command.on("execute", function (args) {
            var yaw = {
                angle: mc.thePlayer.rotationYaw
            }
            var pitch = {
                angle: mc.thePlayer.rotationPitch
            }
    
            wrapAngleTo180_float(yaw);
            wrapAngleTo180_float(pitch);
    
            var wasSet = false;
            if (args.length > 1) {
                switch (args[1].toLowerCase()) {
                    case undefined:
                    case null:
                        Chat.print("Wrong arguments. (.rotation [get/set/setYaw/setPitch])");
                        break;
                    case "get":
                        Chat.print("[" + yaw.angle.toFixed(4) + " / " + pitch.angle.toFixed(4) + "] (truncated)");
                        break;
                    case "set":
                        if (args.length >= 4) {
                            yaw.angle = parseFloat(args[2]);
                            pitch.angle = parseFloat(args[3]);
                            if (yaw.angle.isNaN() || pitch.angle.isNaN()) {
                                Chat.print("Wrong arguments. (.rotation set <yaw> <pitch>)");
                                return;
                            }
                            wasSet = true;
                        } else {
                            Chat.print("Not enough arguments. (.rotation set <yaw> <pitch>)");
                            return;
                        }
                        break;
                    case "setyaw":
                        if (args.length >= 3) {
                            yaw.angle = parseFloat(args[2]);
                            if (yaw.angle.isNaN()) {
                                Chat.print("Wrong arguments. (.rotation setYaw <yaw>)");
                                return;
                            }
                            wasSet = true;
                        } else {
                            Chat.print("Not enough arguments. (.rotation setYaw <yaw>)");
                            return;
                        }
                        break;
                    case "setpitch":
                        if (args.length >= 3) {
                            pitch.angle = parseFloat(args[2]);
                            if (pitch.angle.isNaN()) {
                                Chat.print("Wrong arguments. (.rotation setPitch <pitch>)");
                                return;
                            }
                            wasSet = true;
                        } else {
                            Chat.print("Not enough arguments. (.rotation setPitch <pitch>)");
                            return;
                        }
                        break;
                }
    
                if (wasSet) {
                    unwrapAngleFrom180_float(yaw);
                    unwrapAngleFrom180_float(pitch);
                    mc.thePlayer.rotationYaw = yaw.angle;
                    mc.thePlayer.rotationPitch = pitch.angle;
                    Chat.print("Set rotation to [" + yaw.angle.toFixed(4) + " / " + pitch.angle.toFixed(4) + "] (truncated)");
                }
            }
        });
    });
    
    function wrapAngleTo180_float(angleRef) {
        angleRef.angle %= 360.0;
        if (angleRef.angle >= 180.0) angleRef.angle -= 360.0;
        if (angleRef.angle < -180.0) angleRef.angle += 360.0;
    }
    
    function unwrapAngleFrom180_float(angleRef) {
        if (angleRef.angle <= 180.0) angleRef.angle += 360.0;
        if (angleRef.angle > 180.0) angleRef.angle -= 360.0;
        angleRef.angle %= 360.0;
    }
    
    // public static float wrapAngleTo180_float(float value) {
    //     value %= 360.0f;
    //     if (value >= 180.0f) {
    //         value -= 360.0f;
    //     }
    //     if (value < -180.0f) {
    //         value += 360.0f;
    //     }
    //     return value;
    // }
    


  • That's not useful huh



  • @yorik100 everything is usefull



  • If it's Scaffold related then this script is actually useless. LiquidBounce already has a new turn speed, if you did not know.



  • @mems its .rotation related


Log in to reply