var script = registerScript({
    name: "RedeskyVelocity",
    version: "1.0",
    authors: ["Coccocoa's Helper"]
});

var S06PacketUpdateHealth = Java.type('net.minecraft.network.play.server.S06PacketUpdateHealth')
var S12PacketEntityVelocity = Java.type('net.minecraft.network.play.server.S12PacketEntityVelocity')
var S27PacketExplosion = Java.type('net.minecraft.network.play.server.S27PacketExplosion')
var MathHelper = Java.type("net.minecraft.util.MathHelper")
var MSTimer = Java.type("net.ccbluex.liquidbounce.utils.timer.MSTimer")
var timer = new MSTimer()
var hurt = false

script.registerModule({
    name: "RedeskyVelocity",
    description: "A velocity for Redesky",
    category: "Combat",
    settings: {
		mode: Setting.list({
            name: "Mode",
            values: ["Test"],
            default: "Test"
        })
    }
}, function (module) {
	module.on("update", function () {
		if (module.settings.mode.get() == "Test"){
			if (!mc.thePlayer.onGround) {
				if (mc.thePlayer.hurtTime != 0){
                if (hurt) {
					mc.gameSettings.keyBindForward.isKeyDown() == false
                    mc.thePlayer.speedInAir = 0.02
                    mc.thePlayer.motionX *= 0.6
                    mc.thePlayer.motionZ *= 0.6
                }
			}
			} else{
			if (timer.hasTimePassed(80)) {
                hurt = false
                mc.thePlayer.speedInAir = 0.02
				}
			}
		}
	});
    module.on("packet", function (event) {
        var packet = event.getPacket()
		if (packet instanceof S12PacketEntityVelocity) {
			if (mc.thePlayer == null){
				return
			}
            timer.reset()
			hurt = true
		}
		if (packet instanceof S06PacketUpdateHealth) {
            event.cancelEvent()
        }

        if (packet instanceof S27PacketExplosion) {
            event.cancelEvent()
        }
    });
});