var scriptName = "Wtap"; // The name of your script
var scriptVersion = 1.1; // The version of your script 
var scriptAuthor = "ButterChiCken"; // The author of your script (eg. your username)

var C02PacketUseEntity = Java.type("net.mc.network.play.client.C02PacketUseEntity");
var C0BPacketEntityAction = Java.type("net.mc.network.play.client.C0BPacketEntityAction");

var exampleModule = new ExampleModule();
var exampleModuleClient;

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

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

    this.getCategory = function() {
        return "Combat";
    };

    var target;
    this.onAttack = function(event) {
        target = event.getTargetEntity();
    }

    this.onPacket = function(event) {
        var packet = event.getPacket();
        if (packet instanceof C02PacketUseEntity && mc.thePlayer != null && target != null && packet.getEntityFromWorld(mc.theWorld) != mc.thePlayer && mc.thePlayer.getFoodStats().getFoodLevel() > 6) {
            var sprint = mc.thePlayer.isSprinting();
            mc.thePlayer.setSprinting(false);
            mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SPRINTING));
            mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.START_SPRINTING));
            mc.thePlayer.setSprinting(sprint);
        }
    }

}

function onLoad() {
    // Currently this event has to be in every script even if it is not directly needed.
};

function onEnable() {
    exampleModuleClient = moduleManager.registerModule(exampleModule);
};

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