{
return null;
}
double range = MFRConfig.spyglassRange.getInt();
MovingObjectPosition objHit = Minecraft.getMinecraft().renderViewEntity.rayTrace(range, 1.0F);
double blockDist = range;
Vec3 playerPos = Minecraft.getMinecraft().renderViewEntity.getPosition(1.0F);
if(objHit != null)
{
blockDist = objHit.hitVec.distanceTo(playerPos);
}
Vec3 playerLook = Minecraft.getMinecraft().renderViewEntity.getLook(1.0F);
Vec3 playerLookRel = playerPos.addVector(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range);
List<?> list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(
Minecraft.getMinecraft().renderViewEntity,
Minecraft.getMinecraft().renderViewEntity.boundingBox.addCoord(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range).expand(1, 1, 1));
double entityDistTotal = blockDist;
Entity pointedEntity = null;
for(int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
if(entity.canBeCollidedWith())
{
double entitySize = entity.getCollisionBorderSize();
AxisAlignedBB axisalignedbb = entity.boundingBox.expand(entitySize, entitySize, entitySize);
MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(playerPos, playerLookRel);
if(axisalignedbb.isVecInside(playerPos))
{
if(0.0D < entityDistTotal || entityDistTotal == 0.0D)
{
pointedEntity = entity;
entityDistTotal = 0.0D;
}
}
else if(movingobjectposition != null)
{
double entityDist = playerPos.distanceTo(movingobjectposition.hitVec);
if(entityDist < entityDistTotal || entityDistTotal == 0.0D)
{
pointedEntity = entity;
entityDistTotal = entityDist;
}
}
}
}
if(pointedEntity != null && (entityDistTotal < blockDist || objHit == null))
{
objHit = new MovingObjectPosition(pointedEntity);
}
return objHit;
}