Package com.flansmod.common.guns.raytracing

Examples of com.flansmod.common.guns.raytracing.EntityHit


                    else if(dPos.z != 0F)
                      hitLambda = hitPoint.z / dPos.z;
                    if(hitLambda < 0)
                      hitLambda = -hitLambda;
                   
                    hits.add(new EntityHit(entity, hitLambda));
                  }
                }
              }
            }
           
            //We hit something
            if(!hits.isEmpty())
            {
              //Sort the hits according to the intercept position
              Collections.sort(hits);
             
              float swingDistance = dPos.length();
             
              for(BulletHit bulletHit : hits)
              {
                if(bulletHit instanceof PlayerBulletHit)
                {
                  PlayerBulletHit playerHit = (PlayerBulletHit)bulletHit;
                  float damageMultiplier = 1F;
                  switch(playerHit.hitbox.type)
                  {
                  case LEFTITEM : case RIGHTITEM : //Hit a shield. Stop the swing.
                  {
                    data.meleeProgress = data.meleeLength = 0;
                    return;
                  }
                  case HEAD : damageMultiplier = 2F; break;
                  case RIGHTARM : case LEFTARM : damageMultiplier = 0.6F; break;
                  default :
                  }
                 
                  if(playerHit.hitbox.player.attackEntityFrom(getMeleeDamage(player), swingDistance * type.meleeDamage))
                  {
                    //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
                    playerHit.hitbox.player.arrowHitTimer++;
                    playerHit.hitbox.player.hurtResistantTime = playerHit.hitbox.player.maxHurtResistantTime / 2;
                  }
                 
                  if(FlansMod.DEBUG)
                    world.spawnEntityInWorld(new EntityDebugDot(world, new Vector3f(data.lastMeleePositions[k].x + dPos.x * playerHit.intersectTime, data.lastMeleePositions[k].y + dPos.y * playerHit.intersectTime, data.lastMeleePositions[k].z + dPos.z * playerHit.intersectTime), 1000, 1F, 0F, 0F));
                }
                else if(bulletHit instanceof EntityHit)
                {
                  EntityHit entityHit = (EntityHit)bulletHit;
                  if(entityHit.entity.attackEntityFrom(DamageSource.causePlayerDamage(player), swingDistance * type.meleeDamage) && entityHit.entity instanceof EntityLivingBase)
                  {
                    EntityLivingBase living = (EntityLivingBase)entityHit.entity;
                    //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++;
View Full Code Here


            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)
            {
View Full Code Here

TOP

Related Classes of com.flansmod.common.guns.raytracing.EntityHit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.