/// api_version=2  
var script = registerScript({
    name: "NoomFly",
	version: "0.0.1",
	authors: ["1"]
});
script.registerModule({
    name: "NoomFly",
	category: "Fun",
	description: "noom#0681",
	settings: {
		Mode: Setting.list({
			name: "Mode",
			default: "RedeskyLong",
			values: ["RedeskyLong", "RedeskyLong2", "TakaGlide"]
		}),
		RedeskyLongType: Setting.list({
			name: "RedeskyLongType",
			default: "SW",
			values: ["SW", "BW", "Dev"]
		}),
		RedeLongSpeed: Setting.float({
			name: "RedeLongSpeed",
			default: 0.5,
			min: 1,
			max:0
		}),
		RedeLongTimer: Setting.boolean({
			name: "RedeLongTimer",
			default: false
		})
	}
}, function (module) {
	var delay = 0;
	var ng = false;
	var up = 0;
   module.on("update", function() {
   if (module.settings.Mode.get() == "RedeskyLong2") {
		if(!mc.thePlayer.onGround){
			  delay++;
			  if(delay > 2 && !(delay > 4)){
				  if (module.settings.RedeLongTimer.get() == true) {
					  mc.timer.timerSpeed = 3;
				  }
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get();
				  ng = true;
			  }else{
				  mc.timer.timerSpeed = 1;
			  }
		}
			  if(mc.thePlayer.onGround && ng){
				  module.setState(false);
			  }
	   }
	    if (module.settings.Mode.get() == "RedeskyLong") {
		if(!mc.thePlayer.onGround){
			  delay++;
			  if(module.settings.RedeskyLongType.get() == "BW"){
			  if(delay < 7){
				mc.thePlayer.motionY+=0.1;
			  }
			  if(delay > 0 && !(delay > 2)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get();
				   mc.timer.timerSpeed = 0.75;
				   ng = true;
			  }
			  if(delay > 2 && !(delay > 5)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.25;
				  mc.timer.timerSpeed = 0.65;
			  }
			  if(delay > 5 && !(delay > 7)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.35;
				  mc.timer.timerSpeed = 0.45;
			  }
			   if(delay > 7){
				  mc.thePlayer.jumpMovementFactor = 0.02;
				  mc.timer.timerSpeed = 0.25;
			  }
			  }
			  if(module.settings.RedeskyLongType.get() == "Dev"){
				  if(delay < 9){
				mc.thePlayer.motionY+=0.1;
			  }
			  if(delay > 0 && !(delay > 2)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get();
				   mc.timer.timerSpeed = 0.45;
				   ng = true;
			  }
			  if(delay > 2 && !(delay > 5)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.3;
				  mc.timer.timerSpeed = 0.35;
			  }
			  if(delay > 5 && !(delay > 7)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.34;
				  mc.timer.timerSpeed = 0.25;
			  }
			   if(delay > 10){
				  mc.thePlayer.jumpMovementFactor = 0.063;
				  mc.timer.timerSpeed = 0.35;
			  }
			  }
			  if(module.settings.RedeskyLongType.get() == "SW"){
				  if(delay < 5){
				mc.thePlayer.motionY+=0.1;
			  }
			  if(delay > 0 && !(delay > 2)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get();
				  ng = true;
			  }
			   if(delay > 2 && !(delay > 4)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.25;
				 
			  }
			  if(delay > 4 && !(delay > 7)){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.3;
			  }
			   if(delay > 7){
				  mc.thePlayer.jumpMovementFactor = module.settings.RedeLongSpeed.get() - 0.48;
			  }
			  }
		}
			  if(mc.thePlayer.onGround && ng){
				  module.setState(false);
			  }
	   }
	   if (module.settings.Mode.get() == "TakaGlide") {
		   if(!mc.thePlayer.onGround){
			   mc.timer.timerSpeed = (mc.thePlayer.ticksExisted % 2 == 0 ? 0.1 : 1);
			   mc.thePlayer.motionY = (mc.thePlayer.ticksExisted % 2 == 0 ? -0.01 : -0.05);
		   }
	   }
    });
    module.on("enable", function() {
		 if (module.settings.Mode.get() == "RedeskyLong2") {
	   if(mc.thePlayer.onGround){
		   mc.thePlayer.jump();
	   }else{
		   Chat.print("ЕБЛАН НА ЗЕМЛЮ ВСТАНЬ");
	   }
		 }
		 if (module.settings.Mode.get() == "RedeskyLong") {
	   if(mc.thePlayer.onGround){
		   mc.thePlayer.jump();
	   }else{
		   Chat.print("ЕБЛАН НА ЗЕМЛЮ ВСТАНЬ");
	   }
		 }
		 if (module.settings.Mode.get() == "TakaGlide") {
		mc.thePlayer.jump();  
	   }
		 ng = false;
            delay = 0;
			up = 0;
			 
    });
    module.on("disable", function() {
        mc.timer.timerSpeed = 1;
		delay = 0;
		up = 0;
		ng = false;
        mc.thePlayer.capabilities.isFlying = false;
    });
});