@Override
 protected void applyAttackEffectsToEntity(World world, EntityLiving el) {
   double x = el.posX;
   double y = el.posY;
   double z = el.posZ;
   el.clearActivePotions();
   for (int h = 0; h < 5 && !(el instanceof EntityPlayer); h++) {
     ItemStack held = el.getCurrentItemOrArmor(h);
     el.setCurrentItemOrArmor(h, null);
     if (!world.isRemote && held != null) {
       EntityItem ei = new EntityItem(world, x, y, z, held);
       ReikaEntityHelper.addRandomDirVelocity(ei, 0.2);
       ei.delayBeforeCanPickup = 300;
       world.spawnEntityInWorld(ei);
     }
   }
   // ReikaChatHelper.writeEntity(world, el);
   if (el instanceof EntityDragon) {
     ((EntityDragon) el)
         .attackEntityFromPart(
             ((EntityDragon) el).dragonPartHead,
             DamageSource.setExplosionSource(new Explosion(worldObj, this, x, y, z, 20)),
             this.getAttackDamage());
     if (el.isDead || el.getHealth() <= 0) {
       RotaryAchievements.RAILDRAGON.triggerAchievement(gun.getPlacer());
     }
   } else el.attackEntityFrom(DamageSource.generic, this.getAttackDamage());
   if (el instanceof EntityPlayer) {
     if (el.isDead || el.getHealth() <= 0)
       RotaryAchievements.RAILKILLED.triggerAchievement((EntityPlayer) el);
   }
   el.motionX = motionX * power / 15F;
   el.motionY = motionY * power / 15F;
   el.motionZ = motionZ * power / 15F;
 }
Exemple #2
0
  /** Does the first part of the explosion (destroy blocks) */
  public void doExplosionA() {
    HashSet var1 = Sets.newHashSet();
    boolean var2 = true;
    int var4;
    int var5;

    for (int var3 = 0; var3 < 16; ++var3) {
      for (var4 = 0; var4 < 16; ++var4) {
        for (var5 = 0; var5 < 16; ++var5) {
          if (var3 == 0 || var3 == 15 || var4 == 0 || var4 == 15 || var5 == 0 || var5 == 15) {
            double var6 = (double) ((float) var3 / 15.0F * 2.0F - 1.0F);
            double var8 = (double) ((float) var4 / 15.0F * 2.0F - 1.0F);
            double var10 = (double) ((float) var5 / 15.0F * 2.0F - 1.0F);
            double var12 = Math.sqrt(var6 * var6 + var8 * var8 + var10 * var10);
            var6 /= var12;
            var8 /= var12;
            var10 /= var12;
            float var14 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
            double var15 = this.explosionX;
            double var17 = this.explosionY;
            double var19 = this.explosionZ;

            for (float var21 = 0.3F; var14 > 0.0F; var14 -= 0.22500001F) {
              BlockPos var22 = new BlockPos(var15, var17, var19);
              IBlockState var23 = this.worldObj.getBlockState(var22);

              if (var23.getBlock().getMaterial() != Material.air) {
                float var24 =
                    this.exploder != null
                        ? this.exploder.getExplosionResistance(this, this.worldObj, var22, var23)
                        : var23.getBlock().getExplosionResistance((Entity) null);
                var14 -= (var24 + 0.3F) * 0.3F;
              }

              if (var14 > 0.0F
                  && (this.exploder == null
                      || this.exploder.func_174816_a(this, this.worldObj, var22, var23, var14))) {
                var1.add(var22);
              }

              var15 += var6 * 0.30000001192092896D;
              var17 += var8 * 0.30000001192092896D;
              var19 += var10 * 0.30000001192092896D;
            }
          }
        }
      }
    }

    this.affectedBlockPositions.addAll(var1);
    float var30 = this.explosionSize * 2.0F;
    var4 = MathHelper.floor_double(this.explosionX - (double) var30 - 1.0D);
    var5 = MathHelper.floor_double(this.explosionX + (double) var30 + 1.0D);
    int var31 = MathHelper.floor_double(this.explosionY - (double) var30 - 1.0D);
    int var7 = MathHelper.floor_double(this.explosionY + (double) var30 + 1.0D);
    int var32 = MathHelper.floor_double(this.explosionZ - (double) var30 - 1.0D);
    int var9 = MathHelper.floor_double(this.explosionZ + (double) var30 + 1.0D);
    List var33 =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this.exploder,
            new AxisAlignedBB(
                (double) var4,
                (double) var31,
                (double) var32,
                (double) var5,
                (double) var7,
                (double) var9));
    Vec3 var11 = new Vec3(this.explosionX, this.explosionY, this.explosionZ);

    for (int var34 = 0; var34 < var33.size(); ++var34) {
      Entity var13 = (Entity) var33.get(var34);

      if (!var13.func_180427_aV()) {
        double var35 =
            var13.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double) var30;

        if (var35 <= 1.0D) {
          double var16 = var13.posX - this.explosionX;
          double var18 = var13.posY + (double) var13.getEyeHeight() - this.explosionY;
          double var20 = var13.posZ - this.explosionZ;
          double var36 =
              (double) MathHelper.sqrt_double(var16 * var16 + var18 * var18 + var20 * var20);

          if (var36 != 0.0D) {
            var16 /= var36;
            var18 /= var36;
            var20 /= var36;
            double var37 =
                (double) this.worldObj.getBlockDensity(var11, var13.getEntityBoundingBox());
            double var26 = (1.0D - var35) * var37;
            var13.attackEntityFrom(
                DamageSource.setExplosionSource(this),
                (float) ((int) ((var26 * var26 + var26) / 2.0D * 8.0D * (double) var30 + 1.0D)));
            double var28 = EnchantmentProtection.func_92092_a(var13, var26);
            var13.motionX += var16 * var28;
            var13.motionY += var18 * var28;
            var13.motionZ += var20 * var28;

            if (var13 instanceof EntityPlayer) {
              this.field_77288_k.put(
                  (EntityPlayer) var13, new Vec3(var16 * var26, var18 * var26, var20 * var26));
            }
          }
        }
      }
    }
  }