//If we couldn't get a snapshot, use normal entity hitbox calculations
if(data == null || shouldDoNormalHitDetect)
{
MovingObjectPosition mop = player.boundingBox.calculateIntercept(origin.toVec3(), Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ));
if(mop != null)
{
Vector3f hitPoint = new Vector3f(mop.hitVec.xCoord - posX, mop.hitVec.yCoord - posY, mop.hitVec.zCoord - posZ);
float hitLambda = 1F;
if(motion.x != 0F)
hitLambda = hitPoint.x / motion.x;
else if(motion.y != 0F)
hitLambda = hitPoint.y / motion.y;
else if(motion.z != 0F)
hitLambda = hitPoint.z / motion.z;
if(hitLambda < 0)
hitLambda = -hitLambda;
hits.add(new PlayerBulletHit(new PlayerHitbox(player, new RotatedAxes(), new Vector3f(), new Vector3f(), new Vector3f(), EnumHitboxType.BODY), hitLambda));
}
}
}
else
{
Entity entity = (Entity)obj;
if(entity != this && entity != owner && !entity.isDead && (entity instanceof EntityLivingBase || entity instanceof EntityAAGun || entity instanceof EntityGrenade))
{
MovingObjectPosition mop = entity.boundingBox.calculateIntercept(origin.toVec3(), Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ));
if(mop != null)
{
Vector3f hitPoint = new Vector3f(mop.hitVec.xCoord - posX, mop.hitVec.yCoord - posY, mop.hitVec.zCoord - posZ);
float hitLambda = 1F;
if(motion.x != 0F)
hitLambda = hitPoint.x / motion.x;
else if(motion.y != 0F)
hitLambda = hitPoint.y / motion.y;
else if(motion.z != 0F)
hitLambda = hitPoint.z / motion.z;
if(hitLambda < 0)
hitLambda = -hitLambda;
hits.add(new EntityHit(entity, hitLambda));
}
}