public AxisAlignedBB j(Entity var1) {
   return var1.ae() ? var1.getBoundingBox() : null;
 }
예제 #2
0
  public void a() {
    // CraftBukkit start
    if (this.size < 0.1F) {
      return;
    }
    // CraftBukkit end
    HashSet hashset = Sets.newHashSet();
    boolean flag = true;

    int i;
    int j;

    for (int k = 0; k < 16; ++k) {
      for (i = 0; i < 16; ++i) {
        for (j = 0; j < 16; ++j) {
          if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
            double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
            double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
            double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
            double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

            d0 /= d3;
            d1 /= d3;
            d2 /= d3;
            float f = this.size * (0.7F + this.world.random.nextFloat() * 0.6F);
            double d4 = this.posX;
            double d5 = this.posY;
            double d6 = this.posZ;

            for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
              BlockPosition blockposition = new BlockPosition(d4, d5, d6);
              IBlockData iblockdata = this.world.getType(blockposition);

              if (iblockdata.getBlock().getMaterial() != Material.AIR) {
                float f2 =
                    this.source != null
                        ? this.source.a(this, this.world, blockposition, iblockdata)
                        : iblockdata.getBlock().a((Entity) null);

                f -= (f2 + 0.3F) * 0.3F;
              }

              if (f > 0.0F
                  && (this.source == null
                      || this.source.a(this, this.world, blockposition, iblockdata, f))
                  && blockposition.getY() < 256
                  && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions
                hashset.add(blockposition);
              }

              d4 += d0 * 0.30000001192092896D;
              d5 += d1 * 0.30000001192092896D;
              d6 += d2 * 0.30000001192092896D;
            }
          }
        }
      }
    }

    this.blocks.addAll(hashset);
    float f3 = this.size * 2.0F;

    i = MathHelper.floor(this.posX - (double) f3 - 1.0D);
    j = MathHelper.floor(this.posX + (double) f3 + 1.0D);
    int l = MathHelper.floor(this.posY - (double) f3 - 1.0D);
    int i1 = MathHelper.floor(this.posY + (double) f3 + 1.0D);
    int j1 = MathHelper.floor(this.posZ - (double) f3 - 1.0D);
    int k1 = MathHelper.floor(this.posZ + (double) f3 + 1.0D);
    List list =
        this.world.getEntities(
            this.source,
            new AxisAlignedBB(
                (double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1));
    Vec3D vec3d = new Vec3D(this.posX, this.posY, this.posZ);

    for (int l1 = 0; l1 < list.size(); ++l1) {
      Entity entity = (Entity) list.get(l1);

      if (!entity.aW()) {
        double d7 = entity.f(this.posX, this.posY, this.posZ) / (double) f3;

        if (d7 <= 1.0D) {
          double d8 = entity.locX - this.posX;
          double d9 = entity.locY + (double) entity.getHeadHeight() - this.posY;
          double d10 = entity.locZ - this.posZ;
          double d11 = (double) MathHelper.sqrt(d8 * d8 + d9 * d9 + d10 * d10);

          if (d11 != 0.0D) {
            d8 /= d11;
            d9 /= d11;
            d10 /= d11;
            double d12 = (double) this.world.a(vec3d, entity.getBoundingBox());
            double d13 = (1.0D - d7) * d12;

            // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) /
            // 2.0D * 8.0D * (double) f3 + 1.0D)));+                        // CraftBukkit start
            CraftEventFactory.entityDamage = source;
            boolean wasDamaged =
                entity.damageEntity(
                    DamageSource.explosion(this),
                    (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));
            CraftEventFactory.entityDamage = null;
            if (!wasDamaged
                && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock)) {
              continue;
            }
            // CraftBukkit end
            double d14 = EnchantmentProtection.a(entity, d13);

            entity.motX += d8 * d14;
            entity.motY += d9 * d14;
            entity.motZ += d10 * d14;
            if (entity instanceof EntityHuman && !((EntityHuman) entity).abilities.isInvulnerable) {
              this.k.put((EntityHuman) entity, new Vec3D(d8 * d13, d9 * d13, d10 * d13));
            }
          }
        }
      }
    }
  }