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)
{
EntityHit entityHit = (EntityHit)bulletHit;
if(entityHit.entity.attackEntityFrom(getBulletDamage(false), damage * type.damageVsLiving) && entityHit.entity instanceof EntityLivingBase)
{
EntityLivingBase living = (EntityLivingBase)entityHit.entity;
for(PotionEffect effect : type.hitEffects)
{