var scriptName = "Rotation";
var scriptAuthor = "ProtectName";
var scriptVersion = 1.0;

var C06PacketPlayerPosLook = Java.type('net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook');
var C05PacketPlayerLook = Java.type('net.minecraft.network.play.client.C03PacketPlayer.C05PacketPlayerLook');
var S08PacketPlayerPosLook = Java.type("net.minecraft.network.play.server.S08PacketPlayerPosLook");
var headRotationsModule = moduleManager.getModule("HeadRotations");
var killAuraModule = moduleManager.getModule("KillAura");
var scaffoldModule = moduleManager.getModule("Scaffold");
var towerModule = moduleManager.getModule("Tower");
var killAuraSlientRotation = killAuraModule.getValue("SilentRotation");

var test = new test();
var testClient;

function test() {

    this.getName = function() {
        return "Rotation";
    };

    this.getDescription = function() {
        return headRotationsModule.getDescription();
    };

    this.getCategory = function() {
        return "Render";
    };
        var playeryaw;
    var hrState;
    this.onEnable = function() {
        playeryaw = null;
        hrState = headRotationsModule.getState();
    }
    this.onDisable = function() {
        playeryaw = null;
        headRotationsModule.setState(hrState);
    }
    var player = null;
    this.onUpdate = function() {
        if(!headRotationsModule.getState())
            headRotationsModule.setState(true);
        if(player != null)
            player = null;
    }
    this.onAttack = function(event) {
         player = event.getTargetEntity();
    }
    this.onPacket = function(event) {
        var packet = event.getPacket();
        if(scaffoldModule.getState() || towerModule.getState() || (killAuraModule.getState() && killAuraSlientRotation.get()))
        if(packet instanceof C06PacketPlayerPosLook || packet instanceof C05PacketPlayerLook || packet instanceof S08PacketPlayerPosLook){
            playeryaw = packet.getYaw();
            mc.thePlayer.renderYawOffset = packet.getYaw();
            mc.thePlayer.rotationYawHead = packet.getYaw();
        }
        else if(player != null || scaffoldModule.getState() || towerModule.getState()){
            mc.thePlayer.renderYawOffset = playeryaw;
            mc.thePlayer.rotationYawHead = mc.thePlayer.renderYawOffset;
        }
        
    }
}

function onLoad() {

};

function onEnable() {
    testClient = moduleManager.registerModule(test);
};

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