var scriptName = "HytZoomFly";
var scriptVersion = 2.0;
var scriptAuthor = "神帝"
var BlinkModule = moduleManager.getModule("Blink");
var HytZoomFly = new HytZoomFly();
var client;

var C00PacketKeepAlive = Java.type('net.minecraft.network.play.client.C00PacketKeepAlive')
var MovementUtils = Java.type('net.ccbluex.liquidbounce.utils.MovementUtils')

function HytZoomFly() {
	var Mode = value.createList("Mode", ["Slow", "Packet"], "Slow");
	var Speed = value.createFloat("Speed", 0, 0, 5);
	
    this.getName = function() {
        return "HytZoomFly";
    };
    this.getDescription = function() {
        return "HytZoomFly";
    };
    this.getCategory = function() {
        return "Fun";
    };
    this.onEnable = function() {
		BlinkModule.setState(true);
    };
    this.onDisable = function() {
		BlinkModule.setState(false);
        mc.timer.timerSpeed = 1
        mc.thePlayer.noClip = false
    }
    this.onUpdate = function() {
					    switch(Mode.get()) {
			    case "Slow":	
        mc.timer.timerSpeed = Speed.get()
        mc.thePlayer.noClip = true
        mc.thePlayer.fallDistance = 0
        mc.thePlayer.onGround = false
        mc.thePlayer.capabilities.isFlying = false
        mc.thePlayer.motionX = 0.0
        mc.thePlayer.motionY = 0.0
        mc.thePlayer.motionZ = 0.0
        mc.thePlayer.jumpMovementFactor = Speed.get()
        if (mc.gameSettings.keyBindJump.isKeyDown)
            mc.thePlayer.motionY += Speed.get()
        if (mc.gameSettings.keyBindSneak.isKeyDown)
            mc.thePlayer.motionY -= Speed.get()
		break;
					    case "Packet":	
		                mc.getNetHandler().addToSendQueue(new C00PacketKeepAlive());

                mc.thePlayer.capabilities.isFlying = false;
                mc.thePlayer.motionY = 0;
                mc.thePlayer.motionX = 0;
                mc.thePlayer.motionZ = 0;
                if(mc.gameSettings.keyBindJump.isKeyDown())
                    mc.thePlayer.motionY += Speed.get();
                if(mc.gameSettings.keyBindSneak.isKeyDown())
                    mc.thePlayer.motionY -= Speed.get();
                MovementUtils.strafe(Speed.get());
				break;
						}
    }
		this.addValues = function(values) {
		values.add(Mode);
		values.add(Speed);
    };
}

function onLoad() {}

function onEnable() {
   HytZoomFlyClient = moduleManager.registerModule(HytZoomFly)
}

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