var script = registerScript({
    name: "RedeskyLongJump",
    version: "1.2",
    authors: ["Maki"]
});

var S08PacketPlayerPosLook = Java.type('net.minecraft.network.play.server.S08PacketPlayerPosLook');

var air;

script.registerModule({
    name: "RedeskyLongJump",
    description: "LongJump for Redesky.",
    category: "Fun",
    settings: {
		dis: Setting.boolean({
            name: "AutoDisable",
            default: true
        })	
	}  
}, function (module) {
    module.on("enable", function () {
		air = 0; 
    });
	
	module.on("disable", function () {
		mc.thePlayer.motionX = 0;
		mc.thePlayer.motionZ = 0;
    });
	
	module.on("packet", function (event) {
		var packet = event.getPacket();
		if (packet instanceof S08PacketPlayerPosLook) {
			moduleManager.getModule("MakiLongJump").setState(false);
		}    
    });

    module.on("move", function (event) {
      	
    });
	
	module.on("update", function () {
 		if (!mc.thePlayer.onGround) {
			air++;
		} else if (air > 3 && module.settings.dis.get()) {
			module.setState(false);
		}
		if (mc.thePlayer.onGround && (!module.settings.dis.get() || air  == 0)) {
			mc.thePlayer.jump();
		}
		mc.thePlayer.jumpMovementFactor = 0.10;
		mc.thePlayer.motionY += 0.05;
    });
});