clientcommands icon indicating copy to clipboard operation
clientcommands copied to clipboard

[Feature] Setting player angle automatically for max elytra distance.

Open Nvertd opened this issue 8 months ago • 3 comments
trafficstars

With the right angles, you can fly infinitely (or untill your elytra breaks) and even gain height with just 40 blocks of height. (https://www.youtube.com/watch?v=F69K1-cMaf8)

Would love to see this becoming a feature.

Nvertd avatar Feb 26 '25 01:02 Nvertd

i think some hack clients alr have this

sudosign avatar Feb 27 '25 15:02 sudosign

i think some hack clients alr have this

Not sure how that's relevant to this issue

Earthcomputer avatar Feb 27 '25 16:02 Earthcomputer

Inspired by that YouTube video, I wrote this JsMacros script in JavaScript:

Autopilot
const AUTOPILOT_TOGGLE_KEY = "autopilot";
const DESCEND_PITCH_LIMIT = 38;
const ASCEND_PITCH_LIMIT = -47;
const SPEED_THRESHOLD = 42;
const DESCEND_PITCH_INCREMENT = 0.5;
const ASCEND_PITCH_INCREMENT = 5;

let isAutopilotEnabled = !GlobalVars.getBoolean(AUTOPILOT_TOGGLE_KEY);
GlobalVars.putBoolean(AUTOPILOT_TOGGLE_KEY, isAutopilotEnabled);

if (isAutopilotEnabled) {
    const player = Player.getPlayer();
    const playerYaw = player.getYaw();
    let descending = true;
    let currentPitch;

    if (player.isFallFlying()) {
        player.lookAt(playerYaw, DESCEND_PITCH_LIMIT);
    }

    while (player.isFallFlying()) {
        currentPitch = player.getPitch();

        if (descending) {
            player.lookAt(playerYaw, Math.min(currentPitch + DESCEND_PITCH_INCREMENT, DESCEND_PITCH_LIMIT));
            if (player.getSpeed() >= SPEED_THRESHOLD) {
                descending = false;
            }
        } else {
            player.lookAt(playerYaw, Math.max(currentPitch - ASCEND_PITCH_INCREMENT, ASCEND_PITCH_LIMIT));
            if (player.getPitch() <= ASCEND_PITCH_LIMIT) {
                descending = true;
            }
        }

        Client.waitTick();
        if (!GlobalVars.getBoolean(AUTOPILOT_TOGGLE_KEY)) {
            break;
        }
    }
}

GlobalVars.putBoolean(AUTOPILOT_TOGGLE_KEY, false);

Notes:

  • To use that script, while flying, press the keybind for the script. I don't know how to write that in Java.
  • I tried to fine tune the variables for maximum height gain on each cycle. Another approach might be maximum speed while ensuring not to lose height.
  • To gain the max height, it requires an initial height of about 62 blocks. For a lower initial height, it can start with different values (like lower DESCEND_PITCH_LIMIT and SPEED_THRESHOLD) and slowly change to those values when it gains enough height.
  • One way I can think of to use it in clientcommands is to have a /cautopilot [on|off] or a config. If it is toggled and the player has enough height from the ground, the autopilot will trigger.

m-sarabi avatar Mar 20 '25 23:03 m-sarabi