var scriptName = "FinesseBlinkAddition";
var scriptVersion = 1.0;
var scriptAuthor = "yorik100";
var blinkModule = moduleManager.getModule("Blink");
var C00PacketKeepAlive = Java.type("net.minecraft.network.play.client.C00PacketKeepAlive");
var C05PacketPlayerLook = Java.type("net.minecraft.network.play.client.C03PacketPlayer.C05PacketPlayerLook");
var C07PacketPlayerDigging = Java.type("net.minecraft.network.play.client.C07PacketPlayerDigging");
var C09PacketHeldItemChange = Java.type("net.minecraft.network.play.client.C09PacketHeldItemChange");
var C0FPacketConfirmTransaction = Java.type("net.minecraft.network.play.client.C0FPacketConfirmTransaction");
var C13PacketPlayerAbilities = Java.type("net.minecraft.network.play.client.C13PacketPlayerAbilities");
var blinkModule = moduleManager.getModule("Blink");
var Class = Java.type("java.lang.Class");
var LiquidBounce = Java.type("net.ccbluex.liquidbounce.LiquidBounce");
var Blink = Java.type("net.ccbluex.liquidbounce.features.module.modules.player.Blink");

Math.radians = function (degrees) {
    return degrees * Math.PI / 180;
};
var finesseBlinkAddition = new FinesseBlinkAddition();

var client;

function FinesseBlinkAddition() {
    var KeepAlive = value.createBoolean("KeepAlive", true);
    var PlayerLook = value.createBoolean("PlayerLook", false);
    var ConfirmPacket = value.createBoolean("ConfirmPacket", false);
    var AbilityPacket = value.createBoolean("AbilityPacket", false);
    this.addValues = function (values) {
	values.add(KeepAlive);
	values.add(PlayerLook);
	values.add(ConfirmPacket);
	values.add(AbilityPacket);
	}
    this.getName = function () {
        return "BlinkAddition";
    };

    this.getDescription = function () {
        return "BlinkAddition";
    };

    this.getCategory = function () {
        return "Player";
    };
    this.onEnable = function () {
	this.enabled = true;
	blinkModule.setState(true);
	}
    this.onPacket = function (event) {
        var packet = event.getPacket();
        if (((packet instanceof C00PacketKeepAlive && KeepAlive.get()) || (packet instanceof C05PacketPlayerLook && PlayerLook.get()) || (packet instanceof C0FPacketConfirmTransaction && ConfirmPacket.get()) || (packet instanceof C13PacketPlayerAbilities && AbilityPacket.get())) && mc.thePlayer != null && blinkModule.getState() && this.enabled) {
            packetField = Class.forName("net.ccbluex.liquidbounce.features.module.modules.player.Blink").getDeclaredField("packets");
            packetField.setAccessible(true);
            disableLogger = Class.forName("net.ccbluex.liquidbounce.features.module.modules.player.Blink").getDeclaredField("disableLogger");
            disableLogger.setAccessible(true);
			if (!disableLogger.get(LiquidBounce.moduleManager.getModule(Blink.class))){
            var packeting = packetField.get(LiquidBounce.moduleManager.getModule(Blink.class));
            packeting.add(packet);
            packetField.set(LiquidBounce.moduleManager.getModule(Blink.class), packeting);
			}
            event.cancelEvent();
        }
}
    this.onUpdate = function () {
	blinkModule.setState(true);
	}
    this.onDisable = function () {
	this.enabled = false;
	blinkModule.setState(false);
	}
}

function onLoad() {}

function onEnable() {
    client = moduleManager.registerModule(finesseBlinkAddition);
}

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