var scriptName = "HypFly"
var scriptVersion = 1.0
var scriptAuthor = "yorik100" 

var Title = new Title()
var client
var C03PacketPlayer = Java.type('net.minecraft.network.play.client.C03PacketPlayer');
var S02PacketChat = Java.type('net.minecraft.network.play.server.S02PacketChat');
var C04PacketPlayerPosition = Java.type('net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition')
var C05PacketPlayerLook = Java.type('net.minecraft.network.play.client.C03PacketPlayer.C05PacketPlayerLook');
var C06PacketPlayerPosLook = Java.type('net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook');
var S08PacketPlayerPosLook = Java.type("net.minecraft.network.play.server.S08PacketPlayerPosLook");
var BlockPos = Java.type("net.minecraft.util.BlockPos");
var Strafe = moduleManager.getModule('Strafe');
var mario = 0;
var luigi = 1337;
var AAAA = false;


// Converts from degrees to radians.
Math.radians = function(degrees) {
	return degrees * Math.PI / 180;
};

// Converts from radians to degrees.
Math.degrees = function(radians) {
	return radians * 180 / Math.PI;
};


function Title() {

	this.getName = function() {
		return "RedeskyFly"
	}

	this.getDescription = function() {
		return "Fly by yorik100 & CanYun" //代码来自 yorik100 AntiFall
	}

	this.getCategory = function() {
		return "Fun"
	}
	var VoidOnly = value.createBoolean("VoidOnly", true);
	var AutoStrafe = value.createBoolean("Experimental", true);
	var MinFallenBlocks = value.createInteger("MaxDrop", 8, 1, 30);
	var FlyGet = value.createInteger("JumpHeight", 200, 100, 500);
	var PosX = value.createInteger("JumpDistance", 20, 0, 200);
	var Debug = value.createBoolean("Debug", false);

	this.addValues = function(values) {
		values.add(FlyGet);
		values.add(PosX);
		values.add(VoidOnly);
		values.add(AutoStrafe);
		values.add(MinFallenBlocks);
		values.add(Debug);
		
	}

	this.onMove = function(event) {
		if (VoidOnly.get() && mc.thePlayer.fallDistance >= MinFallenBlocks.get() && mc.thePlayer.motionY <= 0 && (AAAA == false || mc.thePlayer.posY <= mario) && mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox()
				.offset(0, 0, 0)
				.expand(0, 0, 0))
			.isEmpty() && mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox()
				.offset(0, -10002.25, 0)
				.expand(0, -10003.75, 0))
			.isEmpty()) {
			mc.thePlayer.motionY = FlyGet.get() * 0.01;
			mc.thePlayer.motionX = PosX.get() * 0.01;
			mc.thePlayer.motionZ = 0;
			event.setX(0)
			event.setZ(0)
			mario = mc.thePlayer.posY;
			AAAA = true;
			if(AutoStrafe.get()){
			Strafe.setState(true);
			}
		} else {
			if (!VoidOnly.get() && mc.thePlayer.fallDistance >= MinFallenBlocks.get() && mc.thePlayer.motionY <= 0 && (AAAA == false || mc.thePlayer.posY <= mario)) {
				mc.thePlayer.motionY = FlyGet.get() * 0.01;
				mc.thePlayer.motionX = PosX.get() * 0.01;
				mc.thePlayer.motionZ = 0;
				event.setX(0)
				event.setZ(0)
				mario = mc.thePlayer.posY;
				AAAA = true;
				if(AutoStrafe.get()){
				Strafe.setState(true);
				}
			}
		}
		if (mc.thePlayer.onGround) {
			mario = 0;
			AAAA = false;
			if(AutoStrafe.get()){
			Strafe.setState(false);
			}

		}
		if(Debug.get()){
		 luigi = (mario * 0.5)
		 chat.print("Debug = " + luigi)
		}

	}

		
	this.onDisable = function() {
		mario = 0;
		AAAA = false;
		if(AutoStrafe.get()){
		Strafe.setState(false);
		}
	}
}




var Display = Java.type('org.lwjgl.opengl.Display')

function onLoad() {}

function onEnable() {
	client = moduleManager.registerModule(Title)
}

function onDisable() {
	moduleManager.unregisterModule(client)
}