~///api_version=2
(script = registerScript({
    name: "Redesky LongJump",
    version: "1.2",
    authors: ["Arcane", "CH / Gabriel / Coccocoa's Helper", "Spucky7"]
})).import("Core.lib");

var blinkModule = moduleManager.getModule("Blink");
var thismodule = moduleManager.getModule("RedeskyLongJump");
var ticks = 0;
var jumped = false;

module = {
    name: "RedeskyLongJump",
    category: "Movement",
    values: [
        options = value.createList("Glide-Modes", ["Normal", "Glide","Custom", "Off"], "Normal"),
        ticksValue = value.createInteger("Ticks", 21, 1, 25),
        timerValue = value.createFloat("Timer", 1.5, 0.1, 3.5),
        xzMultiplier = value.createFloat("XZ-Multiplier", 0.9, 0.1, 1),
        yMultiplier = value.createFloat("Y-Multiplier", 0.77, 0.1, 1),
        glidevalue = value.createFloat("Glide Motion", 0.03, 0.01, 0.6),
        glide = value.createBoolean("Custom Glide", true),
        blink = value.createBoolean("Blink", true),
        autojump = value.createBoolean("AutoJump", true),
        autodisable = value.createBoolean("AutoDisable", true),
        timeronlyoffground = value.createBoolean("TimerOnlyOffGround", true)
    ],
    onEnable: function() {
        ticks = 0;
    },
    onDisable: function() {
        mc.timer.timerSpeed = 1;
        if(blink.get()) {
            if(blinkModule.getState()) {
                blinkModule.setState(false);
            }
        }
        jumped = false;
        },
    onUpdate: function() {
        if(autodisable.get()) {
            if(jumped || autojump.get()) {
                if(ticks > 4) {
                    if(mc.thePlayer.onGround) {
                        RedeskyLongJumpModule.state = false;
                        mc.timer.timerSpeed = 1;
                        onDisable();
                         if(blink.get()) {
                         if(blinkModule.getState()) {
                           //   blinkModule.setState(false);
                         }           
                        }
                         jumped = false;
                    }
                   
                }
            }
        }
        if(timeronlyoffground.get()) {
            if(!mc.thePlayer.onGround) {
            mc.timer.timerSpeed = timerValue.get();
            } else {
                mc.timer.timerSpeed = 1;
            }
        } else {
            mc.timer.timerSpeed = timerValue.get();
        }
        if(options.get().equalsIgnoreCase("Custom")) {
        if (ticks < ticksValue.get()) {
            if(!autojump.get()) {
            mc.thePlayer.motionY *= yMultiplier.get();
        }
            mc.thePlayer.motionX *= xzMultiplier.get();
            mc.thePlayer.motionZ *= xzMultiplier.get();
            if(!jumped) {
                if(mc.thePlayer.motionY > 0) {
                    jumped = true;
                }
                ticks = 0;
            }
            if(autojump.get() || jumped) {
                mc.thePlayer.jump();
            }
            
        }
        if (glide.get()) {
            mc.thePlayer.motionY += glidevalue.get();
        }
    }
    if(options.get().equalsIgnoreCase("Normal")) {
        if (ticks < ticksValue.get()) {
            if(!autojump.get()) {
            mc.thePlayer.motionY *= yMultiplier.get();
            }
            mc.thePlayer.motionX *= xzMultiplier.get();
            mc.thePlayer.motionZ *= xzMultiplier.get();

            if(!jumped) {
                if(mc.thePlayer.motionY > 0) {
                    jumped = true;
                }
                ticks = 0;
            }
            if(autojump.get() || jumped) {
                mc.thePlayer.jump();
            }
        }
    }
    if(options.get().equalsIgnoreCase("Off")) {
        if (ticks < ticksValue.get()) {
            if(!autojump.get()) {
            if(mc.thePlayer.motionY > 0) {
            mc.thePlayer.motionY *= yMultiplier.get();
            }
        }
            mc.thePlayer.motionX *= xzMultiplier.get();
            mc.thePlayer.motionZ *= xzMultiplier.get();

            if(!jumped) {
                if(mc.thePlayer.motionY > 0) {
                    jumped = true;
                }
                ticks = 0;
            }
            if(autojump.get() || jumped) {
                mc.thePlayer.jump();
            }
        }
    }

    if(options.get().equalsIgnoreCase("Glide")) {
        if (ticks < ticksValue.get()) {
            if(!autojump.get()) {
            mc.thePlayer.motionY *= yMultiplier.get();
            }
            mc.thePlayer.motionX *= xzMultiplier.get();
            mc.thePlayer.motionZ *= xzMultiplier.get();
            if(!jumped) {
                if(mc.thePlayer.motionY > 0) {
                    jumped = true;
                }
                ticks = 0;
            }
            if(autojump.get() || jumped) {
                mc.thePlayer.jump();
            }
            
            
        }
        mc.thePlayer.motionY += glidevalue.get();
            
        
    }
    if(blink.get()) {
    if(!blinkModule.getState()) {
        blinkModule.setState(true);
    }
}


        ticks++;
    }
}