@Override
	public void update()
	{
		EntityLiving target = entity.getGoalTarget();
		if(target == null) return;
        double d0 = this.entity.e(target.locX, target.boundingBox.b, target.locZ);
        boolean canSee = this.entity.getEntitySenses().canSee(target);

        if (canSee) {
            ++this.f;
        } else {
            this.f = 0;
        }

        if (d0 <= (double) maxRange*maxRange && this.f >= 20) {
            entity.getNavigation().g();
        } else {
            entity.getNavigation().a(target, this.speed);
        }

        float f1 = MathHelper.sqrt(d0) / 10f;
        if (f1 > 1.0F) {
            f1 = 1.0F;
        }
        
        this.entity.getControllerLook().a(target, 30.0F, 30.0F);
        this.rangedAttackTime = this.rangedAttackTime - 1;
        if (this.rangedAttackTime <= 0) {
            if (d0 <= (double) maxRange*maxRange && canSee) {
				if(customFire != null)
					customFire.fireProjectile(target, f1);
				else
					fireProjectile(target, f1, projectileName);
                this.rangedAttackTime = this.attackSpeed;	//Reset timer to attack speed
            }
        }
	}