}
}
if(!worldObj.isRemote)
{
Vec3 pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
Vec3 nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition hit = this.worldObj.rayTraceBlocks_do_do(pos, nextPos, false, true);
pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if(hit != null)
{
nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(hit.hitVec.xCoord, hit.hitVec.yCoord, hit.hitVec.zCoord);
}
Entity entityHit = null;
List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double closestRange = 0.0D;
double collisionRange = 0.3D;
for(int i = 0, end = list.size(); i < end; ++i)
{
Entity e = (Entity)list.get(i);
if(e.canBeCollidedWith() && (e != _owner))
{
AxisAlignedBB entitybb = e.boundingBox.expand(collisionRange, collisionRange, collisionRange);
MovingObjectPosition entityHitPos = entitybb.calculateIntercept(pos, nextPos);
if(entityHitPos != null)
{
double range = pos.distanceTo(entityHitPos.hitVec);
if((range < closestRange) | closestRange == 0D)
{
entityHit = e;
closestRange = range;
}
}
}
}
if(entityHit != null)
{
hit = new MovingObjectPosition(entityHit);
}
if(hit != null && hit.entityHit != null && hit.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)hit.entityHit;
if(entityplayer.capabilities.disableDamage || (_owner instanceof EntityPlayer && !((EntityPlayer)_owner).func_96122_a(entityplayer)))
{
hit = null;
}
}
if(hit != null && !worldObj.isRemote)
{
if(hit.entityHit != null)
{ // why not spawn explosion at nextPos x/y/z?
worldObj.newExplosion(this, hit.entityHit.posX, hit.entityHit.posY, hit.entityHit.posZ, 4.0F, true, true);
}
else
{
worldObj.newExplosion(this, hit.blockX, hit.blockY, hit.blockZ, 4.0F, true, true);
}
setDead();
}
}
if(_target != null)
{
// At this point, I suspect literally no one on this project actually understands what this does or how it works
Vec3 targetVector = worldObj.getWorldVec3Pool().getVecFromPool(_target.posX - posX, _target.posY - posY, _target.posZ - posZ);
float targetYaw = clampAngle(360 - (float)(Math.atan2(targetVector.xCoord, targetVector.zCoord) * 180.0D / Math.PI), 360, false);
float targetPitch = clampAngle(-(float)(Math.atan2(targetVector.yCoord, Math.sqrt(targetVector.xCoord * targetVector.xCoord + targetVector.zCoord * targetVector.zCoord)) * 180.0D / Math.PI), 360, false);
float yawDifference = clampAngle(targetYaw - rotationYaw, 3, true);
float pitchDifference = clampAngle(targetPitch - rotationPitch, 3, true);