if (movingobjectposition != null)
{
vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int l;
float f1;
for (l = 0; l < list.size(); ++l)
{
Entity entity1 = (Entity) list.get(l);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f3;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)// && movingobjectposition.entityHit != shootingEntity)
{
if (movingobjectposition.entityHit != shootingEntity)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int i1 = MathHelper.ceiling_double_int(f2 * this.damage);
if (this.getIsCritical())
{
i1 += this.rand.nextInt(i1 / 2 + 2);
}
DamageSource damagesource = null;
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (this.shootingEntity == null)
{
damagesource = DamageSource.setExplosionSource(this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 1.5f, true));
}
else
{
damagesource = DamageSource.setExplosionSource(this.worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, 1.5f, true));
}
//this.kill();
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
Entity entityliving = movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
((EntityLivingBase) entityliving).setArrowCountInEntity(((EntityLivingBase) entityliving).getArrowCountInEntity() + 1);
}