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));
}
}
}
}
//Ray trace the bullet by comparing its next position to its current position
Vec3 posVec = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 nextPosVec = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition hit = worldObj.func_147447_a(posVec, nextPosVec, false, true, true);
posVec = Vec3.createVectorHelper(posX, posY, posZ);
if(hit != null)
{
//Calculate the lambda value of the intercept
Vec3 hitVec = posVec.subtract(hit.hitVec);
float lambda = 1;
//Try each co-ordinate one at a time.
if(motionX != 0)
lambda = (float)(hitVec.xCoord / motionX);
else if(motionY != 0)
lambda = (float)(hitVec.yCoord / motionY);
else if(motionZ != 0)
lambda = (float)(hitVec.zCoord / motionZ);
if(lambda < 0)
lambda = -lambda;
hits.add(new BlockHit(hit, lambda));
}
//We hit something
if(!hits.isEmpty())
{
//Sort the hits according to the intercept position
Collections.sort(hits);
for(BulletHit bulletHit : hits)
{
if(bulletHit instanceof DriveableHit)
{
DriveableHit driveableHit = (DriveableHit)bulletHit;
penetratingPower = driveableHit.driveable.bulletHit(this, driveableHit, penetratingPower);
if(FlansMod.DEBUG)
worldObj.spawnEntityInWorld(new EntityDebugDot(worldObj, new Vector3f(posX + motionX * driveableHit.intersectTime, posY + motionY * driveableHit.intersectTime, posZ + motionZ * driveableHit.intersectTime), 1000, 0F, 0F, 1F));
}
else if(bulletHit instanceof PlayerBulletHit)
{
PlayerBulletHit playerHit = (PlayerBulletHit)bulletHit;
penetratingPower = playerHit.hitbox.hitByBullet(this, penetratingPower);
if(FlansMod.DEBUG)
worldObj.spawnEntityInWorld(new EntityDebugDot(worldObj, new Vector3f(posX + motionX * playerHit.intersectTime, posY + motionY * playerHit.intersectTime, posZ + motionZ * playerHit.intersectTime), 1000, 1F, 0F, 0F));
}
else if(bulletHit instanceof EntityHit)