var scriptName = "OldReach";
var scriptVersion = 1.0;
var scriptAuthor = "york";
var EntityLiving = Java.type('net.minecraft.entity.EntityLivingBase');
var EntityFireball = Java.type('net.minecraft.entity.projectile.EntityLargeFireball');
var C02PacketUseEntity = Java.type("net.minecraft.network.play.client.C02PacketUseEntity");

function OldReach() {
    Range = value.createFloat('Range', 4, 0, 8);
    this.addValues = function(values) {
        values.add(Range);
    };
    this.getName = function() {
        return "OldReach";
    };

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

    this.getCategory = function() {
        return "Misc";
    };
	this.onEnable = function() {
		this.hasattackedfortnite = false;
	}
    this.onPacket = function(event) {
        if (mc.theWorld == null || mc.thePlayer == null && moduleManager.getModule("Killaura").getState())
            return;
        packet = event.getPacket();
        if (packet instanceof C02PacketUseEntity && packet.getAction() == C02PacketUseEntity.Action.ATTACK) {
            attackedEntity = packet.getEntityFromWorld(mc.theWorld);
            if (attackedEntity == null)
                return;
            if (mc.thePlayer.getDistanceToEntity(attackedEntity) > Range.get()) {
                event.cancelEvent();
                this.hasattackedfortnite = true;
                this.fortnite = mc.thePlayer.motionX;
                this.fortnite2 = mc.thePlayer.motionZ;
            }
        }
    }
    this.onUpdate = function() {
        moduleManager.getModule("Killaura").getValue("Range").set(Range.get());
        moduleManager.getModule("Killaura").getValue("ThroughWallsRange").set(Range.get());
        if (this.hasattackedfortnite) {
            mc.thePlayer.motionX = this.fortnite;
            mc.thePlayer.motionZ = this.fortnite2;
            this.hasattackedfortnite = false;
        }
    }
}
var OldReach = new OldReach();
var OldReachClient;

function onEnable() {
    OldReachClient = moduleManager.registerModule(OldReach);
};

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