/** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (ridingEntity == null) {
      for (int i = 0; i < worldObj.loadedEntityList.size(); i++) {
        Entity entity = (Entity) worldObj.loadedEntityList.get(i);

        if (((entity instanceof CREEPSEntityCamel) || entity.riddenByEntity == null)
            && (entity instanceof CREEPSEntityCamel)
            && entity.riddenByEntity == null
            && !((CREEPSEntityCamel) entity).tamed) {
          double d = entity.getDistance(posX, posY, posZ);
          CREEPSEntityCamel creepsentitycamel = (CREEPSEntityCamel) entity;

          if (d < 4D && entity.riddenByEntity == null) {
            mountEntity(entity);
          }

          creepsentitycamel.interest = 0;
          creepsentitycamel.tamed = false;
          creepsentitycamel.name = "";

          if (d < 16D && creepsentitycamel.canEntityBeSeen(this)) {
            this.attackEntity(creepsentitycamel, 0);
          }
        }
      }
    } else {
      rotationYaw = ridingEntity.rotationYaw;
    }
  }
  @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;
  }
 private boolean entityInRange(Entity entity, int range) {
   return entity != null && (entity.getDistance(xCoord, yCoord, zCoord) > range);
 }
  /** Does the first part of the explosion (destroy blocks) */
  @Override
  public void doExplosionA() {
    float var1 = explosionSize;
    int var3;
    int var4;
    int var5;
    double var15;
    double var17;
    double var19;

    for (var3 = 0; var3 < field_77289_h; ++var3) {
      for (var4 = 0; var4 < field_77289_h; ++var4) {
        for (var5 = 0; var5 < field_77289_h; ++var5) {
          if (var3 == 0
              || var3 == field_77289_h - 1
              || var4 == 0
              || var4 == field_77289_h - 1
              || var5 == 0
              || var5 == field_77289_h - 1) {
            double var6 = var3 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var8 = var4 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var10 = var5 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var12 = Math.sqrt(var6 * var6 + var8 * var8 + var10 * var10);
            var6 /= var12;
            var8 /= var12;
            var10 /= var12;
            var15 = explosionX;
            var17 = explosionY;
            var19 = explosionZ;
          }
        }
      }
    }

    explosionSize *= 2.0F;
    var3 = MathHelper.floor_double(explosionX - explosionSize - 1.0D);
    var4 = MathHelper.floor_double(explosionX + explosionSize + 1.0D);
    var5 = MathHelper.floor_double(explosionY - explosionSize - 1.0D);
    int var28 = MathHelper.floor_double(explosionY + explosionSize + 1.0D);
    int var7 = MathHelper.floor_double(explosionZ - explosionSize - 1.0D);
    int var29 = MathHelper.floor_double(explosionZ + explosionSize + 1.0D);
    List var9 =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            exploder, AxisAlignedBB.getBoundingBox(var3, var5, var7, var4, var28, var29));

    Vec3 var30 = Vec3.createVectorHelper(explosionX, explosionY, explosionZ);

    for (int var11 = 0; var11 < var9.size(); ++var11) {
      Entity var31 = (Entity) var9.get(var11);
      if (!(var31 instanceof EntityLiving)) {
        continue;
      }
      if (var31 == shootingEntity && !hurtsPlayer) {
        continue;
      }
      double var13 = var31.getDistance(explosionX, explosionY, explosionZ) / explosionSize;
      if (var13 <= 1.0D) {
        var15 = var31.posX - explosionX;
        var17 = var31.posY + var31.getEyeHeight() - explosionY;
        var19 = var31.posZ - explosionZ;
        double var33 = MathHelper.sqrt_double(var15 * var15 + var17 * var17 + var19 * var19);

        if (var33 != 0.0D) {
          var15 /= var33;
          var17 /= var33;
          var19 /= var33;
          double var32 = worldObj.getBlockDensity(var30, var31.boundingBox);
          double var34 = (1.0D - var13) * var32;
          var31.attackEntityFrom(
              DamageSource.causePlayerDamage(shootingEntity),
              (int) ((var34 * var34 + var34) * 6.0D * (explosionSize * 2) + 3.0D));
          var31.motionX += var15 * var34;
          var31.motionY += var17 * var34;
          var31.motionZ += var19 * var34;

          if (var31 instanceof EntityPlayer) {
            field_77288_k.put(
                var31, Vec3.createVectorHelper(var15 * var34, var17 * var34, var19 * var34));
          }
        }
      }
    }

    explosionSize = var1;
  }
 public double getRange() {
   return targetEntity.getDistance(
       this.getTileX() + 0.5, this.getTileY() + 0.5, this.getTileZ() + 0.5);
 }
Beispiel #6
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));
            }
          }
        }
      }
    }
  }