private void tryAbility(EntityLivingBase mob, EntityLivingBase target) {
    if (target == null || !mob.canEntityBeSeen(target)) {
      return;
    }

    if (mob.getDistanceToEntity(target) > MIN_DISTANCE) {
      double diffX = target.posX - mob.posX;
      double diffY =
          target.boundingBox.minY
              + (double) (target.height / 2.0F)
              - (mob.posY + (double) (mob.height / 2.0F));
      double diffZ = target.posZ - mob.posZ;
      mob.renderYawOffset =
          mob.rotationYaw = -((float) Math.atan2(diffX, diffZ)) * 180.0F / (float) Math.PI;

      mob.worldObj.playAuxSFXAtEntity(
          (EntityPlayer) null, 1008, (int) mob.posX, (int) mob.posY, (int) mob.posZ, 0);
      EntityLargeFireball entFB = new EntityLargeFireball(mob.worldObj, mob, diffX, diffY, diffZ);
      double spawnOffset = 2.0D;
      Vec3 mobLook = mob.getLook(1.0F);
      entFB.posX = mob.posX + mobLook.xCoord * spawnOffset;
      entFB.posY = mob.posY + (double) (mob.height / 2.0F) + 0.5D;
      entFB.posZ = mob.posZ + mobLook.zCoord * spawnOffset;
      mob.worldObj.spawnEntityInWorld(entFB);
    }
  }
Esempio n. 2
0
 @Override
 public void activeAbility(World world, EntityLivingBase user, ItemStack is) {
   consumeMana(world, user, is);
   if (!world.isRemote) {
     ESelectorNonHostile sel = new ESelectorNonHostile();
     ESelectorProjectiles sel1 = new ESelectorProjectiles();
     double range = 16;
     List<Entity> list =
         world.getEntitiesWithinAABB(
             Entity.class,
             AxisAlignedBB.getBoundingBox(
                     user.posX, user.posY, user.posZ, user.posX, user.posY, user.posZ)
                 .expand(range, range, range));
     list.remove(user);
     for (Entity e : list) {
       Vector v = FuncHelper.vectorToEntity(e, user).normalize();
       double power = 0.4 * user.getDistanceToEntity(e);
       if (sel1.isEntityApplicable(e)
           || e instanceof EntityLivingBase
               && sel.isEntityApplicable(e) != sel.isEntityApplicable(user)) {
         v = v.reverse();
         power = 3;
       }
       v = v.multiply(power);
       e.motionX += v.x;
       e.motionY += v.y * 0.5;
       e.motionZ += v.z;
     }
   }
 }
Esempio n. 3
0
  private boolean shouldBeFlying() {

    EntityLivingBase attackTarget = getAITarget();

    // if we have an attack target
    if (attackTarget != null) {

      // and the distance is bigger than 2.0
      float distanceToEntity = attackTarget.getDistanceToEntity(this);
      if (distanceToEntity > 2.0f) {
        // lets fly to them!
        return true;
      }
    }
    // if we're still in the "flight" cooldown, we still want to fly
    if (flags.ticksSinceSet(FlagKeys.IS_FLYING) < 20) {
      return true;
    }

    // na, lets not fly
    return false;
  }
Esempio n. 4
0
 public static boolean canSneakAttack(EntityLivingBase source, Entity target) {
   // TODO handle cover, etc.
   return MonsterUtil.isCritable(target)
       && source.getDistanceToEntity(target) <= MathUtil.feetToMeters(30)
       && (source.isInvisible() || isBehind(source, target));
 }