CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    [SCRIPT] .Rotation 1.0.0

    Scripts
    4
    5
    357
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Vonr
      Vonr last edited by Vonr

      .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;
      // }
      
      1 Reply Last reply Reply Quote 0
      • yorik100
        yorik100 last edited by

        That's not useful huh

        hahayes 1 Reply Last reply Reply Quote 0
        • hahayes
          hahayes @yorik100 last edited by

          @yorik100 everything is usefull

          1 Reply Last reply Reply Quote 0
          • M
            mems Moderator last edited by

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

            hahayes 1 Reply Last reply Reply Quote 0
            • hahayes
              hahayes @mems last edited by

              @mems its .rotation related

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              About
              • Terms of Service
              • Privacy Policy
              • Status
              • Contact Us
              Downloads
              • Releases
              • Source code
              • License
              Docs
              • Tutorials
              • CustomHUD
              • AutoSettings
              • ScriptAPI
              Community
              • Forum
              • Guilded
              • YouTube
              • Twitter
              • D.Tube