@SuppressWarnings({"rawtypes", "unchecked"})
  public void doExplosionA() {
    float f = this.explosionSize;
    int i;
    int j;
    int k;
    double d0;
    double d1;
    double d2;

    for (i = 0; i < this.field_77289_h; ++i) {
      for (j = 0; j < this.field_77289_h; ++j) {
        for (k = 0; k < this.field_77289_h; ++k) {
          if (i == 0
              || i == this.field_77289_h - 1
              || j == 0
              || j == this.field_77289_h - 1
              || k == 0
              || k == this.field_77289_h - 1) {
            double d3 = i / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d4 = j / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d5 = k / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
            d3 /= d6;
            d4 /= d6;
            d5 /= d6;
            float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
            d0 = this.explosionX;
            d1 = this.explosionY;
            d2 = this.explosionZ;

            for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
              d0 += d3 * f2;
              d1 += d4 * f2;
              d2 += d5 * f2;
            }
          }
        }
      }
    }

    this.explosionSize *= 2.0F;
    i = MathHelper.floor_double(this.explosionX - this.explosionSize - 1.0D);
    j = MathHelper.floor_double(this.explosionX + this.explosionSize + 1.0D);
    k = MathHelper.floor_double(this.explosionY - this.explosionSize - 1.0D);
    int l1 = MathHelper.floor_double(this.explosionY + this.explosionSize + 1.0D);
    int i2 = MathHelper.floor_double(this.explosionZ - this.explosionSize - 1.0D);
    int j2 = MathHelper.floor_double(this.explosionZ + this.explosionSize + 1.0D);
    List list =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this.exploder, AxisAlignedBB.getBoundingBox(i, k, i2, j, l1, j2));
    Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ);

    for (int k2 = 0; k2 < list.size(); ++k2) {
      Entity entity = (Entity) list.get(k2);
      double d7 =
          entity.getDistance(this.explosionX, this.explosionY, this.explosionZ)
              / this.explosionSize;

      if (d7 <= 1.0D) {
        d0 = entity.posX - this.explosionX;
        d1 = entity.posY + entity.getEyeHeight() - this.explosionY;
        d2 = entity.posZ - this.explosionZ;
        double d8 = MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);

        if (d8 != 0.0D) {
          d0 /= d8;
          d1 /= d8;
          d2 /= d8;
          double d9 = this.worldObj.getBlockDensity(vec3, entity.boundingBox);
          double d10 = (1.0D - d7) * d9;
          double d11 = EnchantmentProtection.func_92092_a(entity, d10);
          entity.attackEntityFrom(DamageSource.generic, 0.0001F);
          entity.motionX += (d0 * d11);
          entity.motionY += (d1 * d11) * explosionPower;
          entity.motionZ += (d2 * d11);

          if (entity instanceof EntityPlayer)
            this.field_77288_k.put(entity, Vec3.createVectorHelper(d0 * d10, d1 * d10, d2 * d10));
        }
      }
    }

    this.explosionSize = f;
  }
示例#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));
            }
          }
        }
      }
    }
  }