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)
{
living.addPotionEffect(new PotionEffect(effect));
}
//If the attack was allowed, we should remove their immortality cooldown so we can shoot them again. Without this, any rapid fire gun become useless
living.arrowHitTimer++;
living.hurtResistantTime = living.maxHurtResistantTime / 2;
}
if(type.setEntitiesOnFire)
entityHit.entity.setFire(20);
penetratingPower -= 1F;
if(FlansMod.DEBUG)
worldObj.spawnEntityInWorld(new EntityDebugDot(worldObj, new Vector3f(posX + motionX * entityHit.intersectTime, posY + motionY * entityHit.intersectTime, posZ + motionZ * entityHit.intersectTime), 1000, 1F, 1F, 0F));
}
else if(bulletHit instanceof BlockHit)
{
BlockHit blockHit = (BlockHit)bulletHit;
MovingObjectPosition raytraceResult = blockHit.raytraceResult;
//If the hit wasn't an entity hit, then it must've been a block hit
int xTile = raytraceResult.blockX;
int yTile = raytraceResult.blockY;
int zTile = raytraceResult.blockZ;
if(FlansMod.DEBUG)
worldObj.spawnEntityInWorld(new EntityDebugDot(worldObj, new Vector3f(raytraceResult.hitVec.xCoord, raytraceResult.hitVec.yCoord, raytraceResult.hitVec.zCoord), 1000, 0F, 1F, 0F));
Block block = worldObj.getBlock(xTile, yTile, zTile);
Material mat = block.getMaterial();
//If the bullet breaks glass, and can do so according to FlansMod, do so.
if(type.breaksGlass && mat == Material.glass)