Exemple #1
0
 public AxisAlignedBB e(World world, int i, int j, int k) {
   return AxisAlignedBB.b(
       (double) i + this.minX,
       (double) j + this.minY,
       (double) k + this.minZ,
       (double) i + this.maxX,
       (double) j + this.maxY,
       (double) k + this.maxZ);
 }
 /**
  * Checks if the player is on ground.
  *
  * @return true, if the player is on ground
  */
 public boolean isOnGround() {
   if (onGround == null) {
     final double d0 = 0.01D;
     onGround =
         BlockProperties.isOnGround(
             getBlockAccess(),
             minX - d0,
             minY - yOnGround,
             minZ - d0,
             maxX + d0,
             minY + 0.25,
             maxZ + d0);
     if (!onGround) {
       // TODO: Probably check other ids too before doing this ?
       final double d1 = 0.25D;
       final AxisAlignedBB box =
           useBox.b(
               minX - d1,
               minY - getyOnGround() - d1,
               minZ - d1,
               maxX + d1,
               minY + 0.25 + d1,
               maxZ + d1);
       @SuppressWarnings("rawtypes")
       final List list = worldServer.getEntities(entityPlayer, box);
       @SuppressWarnings("rawtypes")
       Iterator iterator = list.iterator();
       while (iterator.hasNext()) {
         final Entity entity = (Entity) iterator.next();
         final EntityType type = entity.getBukkitEntity().getType();
         if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
         final AxisAlignedBB otherBox = entity.boundingBox;
         if (box.a > otherBox.d
             || box.d < otherBox.a
             || box.b > otherBox.e
             || box.e < otherBox.b
             || box.c > otherBox.f
             || box.f < otherBox.c) continue;
         else {
           onGround = true;
           break;
         }
       }
     }
   }
   return onGround;
 }
Exemple #3
0
  protected void a(EntityLiving entityliving, boolean flag) {
    if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
      if (entityliving instanceof EntityWolf) {
        EntityWolf entitywolf = (EntityWolf) entityliving;

        if (entitywolf.isTamed() && this.name.equals(entitywolf.getOwnerName())) {
          return;
        }
      }

      if (!(entityliving instanceof EntityHuman) || this.C()) {
        List list =
            this.world.a(
                EntityWolf.class,
                AxisAlignedBB.b(
                        this.locX,
                        this.locY,
                        this.locZ,
                        this.locX + 1.0D,
                        this.locY + 1.0D,
                        this.locZ + 1.0D)
                    .grow(16.0D, 4.0D, 16.0D));
        Iterator iterator = list.iterator();

        while (iterator.hasNext()) {
          Entity entity = (Entity) iterator.next();
          EntityWolf entitywolf1 = (EntityWolf) entity;

          if (entitywolf1.isTamed()
              && entitywolf1.I() == null
              && this.name.equals(entitywolf1.getOwnerName())
              && (!flag || !entitywolf1.isSitting())) {
            entitywolf1.setSitting(false);
            entitywolf1.setTarget(entityliving);
          }
        }
      }
    }
  }
  public void w_() {
    super.w_();
    if (this.lifeTicks == 2) {
      this.world.makeSound(
          this.locX,
          this.locY,
          this.locZ,
          "ambient.weather.thunder",
          10000.0F,
          0.8F + this.random.nextFloat() * 0.2F);
      this.world.makeSound(
          this.locX,
          this.locY,
          this.locZ,
          "random.explode",
          2.0F,
          0.5F + this.random.nextFloat() * 0.2F);
    }

    --this.lifeTicks;
    if (this.lifeTicks < 0) {
      if (this.c == 0) {
        this.die();
      } else if (this.lifeTicks < -this.random.nextInt(10)) {
        --this.c;
        this.lifeTicks = 1;
        this.a = this.random.nextLong();
        if (this.world.areChunksLoaded(
            MathHelper.floor(this.locX),
            MathHelper.floor(this.locY),
            MathHelper.floor(this.locZ),
            10)) {
          int i = MathHelper.floor(this.locX);
          int j = MathHelper.floor(this.locY);
          int k = MathHelper.floor(this.locZ);

          if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
            this.world.setTypeId(i, j, k, Block.FIRE.id);
          }
        }
      }
    }

    if (this.lifeTicks >= 0) {
      double d0 = 3.0D;
      List list =
          this.world.b(
              (Entity) this,
              AxisAlignedBB.b(
                  this.locX - d0,
                  this.locY - d0,
                  this.locZ - d0,
                  this.locX + d0,
                  this.locY + 6.0D + d0,
                  this.locZ + d0));

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

        entity.a(this);
      }

      this.world.s = 2;
    }
  }
Exemple #5
0
  public void move(double d0, double d1, double d2) {
    if (this.T) {
      this.a(this.getBoundingBox().c(d0, d1, d2));
      this.recalcPosition();
    } else {
      this.world.methodProfiler.a("move");
      double d3 = this.locX;
      double d4 = this.locY;
      double d5 = this.locZ;

      if (this.H) {
        this.H = false;
        d0 *= 0.25D;
        d1 *= 0.05000000074505806D;
        d2 *= 0.25D;
        this.motX = 0.0D;
        this.motY = 0.0D;
        this.motZ = 0.0D;
      }

      double d6 = d0;
      double d7 = d1;
      double d8 = d2;
      boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman;

      if (flag) {
        double d9;

        for (d9 = 0.05D;
            d0 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, 0.0D)).isEmpty();
            d6 = d0) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }
        }

        for (;
            d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(0.0D, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }

        for (;
            d0 != 0.0D
                && d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }

          d6 = d0;
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }
      }

      List list = this.world.getCubes(this, this.getBoundingBox().a(d0, d1, d2));
      AxisAlignedBB axisalignedbb = this.getBoundingBox();

      AxisAlignedBB axisalignedbb1;

      for (Iterator iterator = list.iterator();
          iterator.hasNext();
          d1 = axisalignedbb1.b(this.getBoundingBox(), d1)) {
        axisalignedbb1 = (AxisAlignedBB) iterator.next();
      }

      this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
      boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D;

      AxisAlignedBB axisalignedbb2;
      Iterator iterator1;

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d0 = axisalignedbb2.a(this.getBoundingBox(), d0)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(d0, 0.0D, 0.0D));

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d2 = axisalignedbb2.c(this.getBoundingBox(), d2)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(0.0D, 0.0D, d2));
      if (this.S > 0.0F && flag1 && (d6 != d0 || d8 != d2)) {
        double d10 = d0;
        double d11 = d1;
        double d12 = d2;
        AxisAlignedBB axisalignedbb3 = this.getBoundingBox();

        this.a(axisalignedbb);
        d1 = (double) this.S;
        List list1 = this.world.getCubes(this, this.getBoundingBox().a(d6, d1, d8));
        AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
        AxisAlignedBB axisalignedbb5 = axisalignedbb4.a(d6, 0.0D, d8);
        double d13 = d1;

        AxisAlignedBB axisalignedbb6;

        for (Iterator iterator2 = list1.iterator();
            iterator2.hasNext();
            d13 = axisalignedbb6.b(axisalignedbb5, d13)) {
          axisalignedbb6 = (AxisAlignedBB) iterator2.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, d13, 0.0D);
        double d14 = d6;

        AxisAlignedBB axisalignedbb7;

        for (Iterator iterator3 = list1.iterator();
            iterator3.hasNext();
            d14 = axisalignedbb7.a(axisalignedbb4, d14)) {
          axisalignedbb7 = (AxisAlignedBB) iterator3.next();
        }

        axisalignedbb4 = axisalignedbb4.c(d14, 0.0D, 0.0D);
        double d15 = d8;

        AxisAlignedBB axisalignedbb8;

        for (Iterator iterator4 = list1.iterator();
            iterator4.hasNext();
            d15 = axisalignedbb8.c(axisalignedbb4, d15)) {
          axisalignedbb8 = (AxisAlignedBB) iterator4.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, 0.0D, d15);
        AxisAlignedBB axisalignedbb9 = this.getBoundingBox();
        double d16 = d1;

        AxisAlignedBB axisalignedbb10;

        for (Iterator iterator5 = list1.iterator();
            iterator5.hasNext();
            d16 = axisalignedbb10.b(axisalignedbb9, d16)) {
          axisalignedbb10 = (AxisAlignedBB) iterator5.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, d16, 0.0D);
        double d17 = d6;

        AxisAlignedBB axisalignedbb11;

        for (Iterator iterator6 = list1.iterator();
            iterator6.hasNext();
            d17 = axisalignedbb11.a(axisalignedbb9, d17)) {
          axisalignedbb11 = (AxisAlignedBB) iterator6.next();
        }

        axisalignedbb9 = axisalignedbb9.c(d17, 0.0D, 0.0D);
        double d18 = d8;

        AxisAlignedBB axisalignedbb12;

        for (Iterator iterator7 = list1.iterator();
            iterator7.hasNext();
            d18 = axisalignedbb12.c(axisalignedbb9, d18)) {
          axisalignedbb12 = (AxisAlignedBB) iterator7.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, 0.0D, d18);
        double d19 = d14 * d14 + d15 * d15;
        double d20 = d17 * d17 + d18 * d18;

        if (d19 > d20) {
          d0 = d14;
          d2 = d15;
          this.a(axisalignedbb4);
        } else {
          d0 = d17;
          d2 = d18;
          this.a(axisalignedbb9);
        }

        d1 = (double) (-this.S);

        AxisAlignedBB axisalignedbb13;

        for (Iterator iterator8 = list1.iterator();
            iterator8.hasNext();
            d1 = axisalignedbb13.b(this.getBoundingBox(), d1)) {
          axisalignedbb13 = (AxisAlignedBB) iterator8.next();
        }

        this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
        if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) {
          d0 = d10;
          d1 = d11;
          d2 = d12;
          this.a(axisalignedbb3);
        }
      }

      this.world.methodProfiler.b();
      this.world.methodProfiler.a("rest");
      this.recalcPosition();
      this.positionChanged = d6 != d0 || d8 != d2;
      this.E = d7 != d1;
      this.onGround = this.E && d7 < 0.0D;
      this.F = this.positionChanged || this.E;
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D);
      int k = MathHelper.floor(this.locZ);
      BlockPosition blockposition = new BlockPosition(i, j, k);
      Block block = this.world.getType(blockposition).getBlock();

      if (block.getMaterial() == Material.AIR) {
        Block block1 = this.world.getType(blockposition.down()).getBlock();

        if (block1 instanceof BlockFence
            || block1 instanceof BlockCobbleWall
            || block1 instanceof BlockFenceGate) {
          block = block1;
          blockposition = blockposition.down();
        }
      }

      this.a(d1, this.onGround, block, blockposition);
      if (d6 != d0) {
        this.motX = 0.0D;
      }

      if (d8 != d2) {
        this.motZ = 0.0D;
      }

      if (d7 != d1) {
        block.a(this.world, this);
      }

      if (this.r_() && !flag && this.vehicle == null) {
        double d21 = this.locX - d3;
        double d22 = this.locY - d4;
        double d23 = this.locZ - d5;

        if (block != Blocks.LADDER) {
          d22 = 0.0D;
        }

        if (block != null && this.onGround) {
          block.a(this.world, blockposition, this);
        }

        this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
        this.N =
            (float)
                ((double) this.N
                    + (double) MathHelper.sqrt(d21 * d21 + d22 * d22 + d23 * d23) * 0.6D);
        if (this.N > (float) this.h && block.getMaterial() != Material.AIR) {
          this.h = (int) this.N + 1;
          if (this.V()) {
            float f =
                MathHelper.sqrt(
                        this.motX * this.motX * 0.20000000298023224D
                            + this.motY * this.motY
                            + this.motZ * this.motZ * 0.20000000298023224D)
                    * 0.35F;

            if (f > 1.0F) {
              f = 1.0F;
            }

            this.makeSound(
                this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
          }

          this.a(blockposition, block);
        }
      }

      try {
        this.checkBlockCollisions();
      } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
        CrashReportSystemDetails crashreportsystemdetails =
            crashreport.a("Entity being checked for collision");

        this.appendEntityCrashDetails(crashreportsystemdetails);
        throw new ReportedException(crashreport);
      }

      boolean flag2 = this.U();

      if (this.world.e(this.getBoundingBox().shrink(0.001D, 0.001D, 0.001D))) {
        this.burn(1);
        if (!flag2) {
          ++this.fireTicks;
          if (this.fireTicks == 0) {
            this.setOnFire(8);
          }
        }
      } else if (this.fireTicks <= 0) {
        this.fireTicks = -this.maxFireTicks;
      }

      if (flag2 && this.fireTicks > 0) {
        this.makeSound(
            "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
        this.fireTicks = -this.maxFireTicks;
      }

      this.world.methodProfiler.b();
    }
  }
Exemple #6
0
 public boolean t() {
   return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.g);
 }
Exemple #7
0
 public boolean r() {
   return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this);
 }
Exemple #8
0
  public void c(double d1, double d2, double d3) {
    if (T) {
      z.d(d1, d2, d3);
      p = (z.a + z.d) / 2D;
      q = (z.b + (double) H) - (double) R;
      r = (z.c + z.f) / 2D;
      return;
    }
    double d4 = p;
    double d5 = r;
    double d6 = d1;
    double d7 = d2;
    double d8 = d3;
    AxisAlignedBB axisalignedbb = z.b();
    boolean flag = A && p();

    if (flag) {
      double d9 = 0.050000000000000003D;

      for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) {
        if (d1 < d9 && d1 >= -d9) {
          d1 = 0.0D;
          continue;
        }
        if (d1 > 0.0D) {
          d1 -= d9;
        } else {
          d1 += d9;
        }
      }

      for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) {
        if (d3 < d9 && d3 >= -d9) {
          d3 = 0.0D;
          continue;
        }
        if (d3 > 0.0D) {
          d3 -= d9;
        } else {
          d3 += d9;
        }
      }
    }
    List list = l.a(this, z.a(d1, d2, d3));

    for (int i1 = 0; i1 < list.size(); i1++) {
      d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2);
    }

    z.d(0.0D, d2, 0.0D);
    if (!F && d7 != d2) {
      d1 = d2 = d3 = 0.0D;
    }
    boolean flag1 = A || d7 != d2 && d7 < 0.0D;

    for (int j1 = 0; j1 < list.size(); j1++) {
      d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1);
    }

    z.d(d1, 0.0D, 0.0D);
    if (!F && d6 != d1) {
      d1 = d2 = d3 = 0.0D;
    }
    for (int k1 = 0; k1 < list.size(); k1++) {
      d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3);
    }

    z.d(0.0D, 0.0D, d3);
    if (!F && d8 != d3) {
      d1 = d2 = d3 = 0.0D;
    }
    if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) {
      double d10 = d1;
      double d12 = d2;
      double d14 = d3;

      d1 = d6;
      d2 = S;
      d3 = d8;
      AxisAlignedBB axisalignedbb1 = z.b();

      z.b(axisalignedbb);
      List list1 = l.a(this, z.a(d1, d2, d3));

      for (int j2 = 0; j2 < list1.size(); j2++) {
        d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2);
      }

      z.d(0.0D, d2, 0.0D);
      if (!F && d7 != d2) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int k2 = 0; k2 < list1.size(); k2++) {
        d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1);
      }

      z.d(d1, 0.0D, 0.0D);
      if (!F && d6 != d1) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int l2 = 0; l2 < list1.size(); l2++) {
        d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3);
      }

      z.d(0.0D, 0.0D, d3);
      if (!F && d8 != d3) {
        d1 = d2 = d3 = 0.0D;
      }
      if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) {
        d1 = d10;
        d2 = d12;
        d3 = d14;
        z.b(axisalignedbb1);
      } else {
        R += 0.5D;
      }
    }
    p = (z.a + z.d) / 2D;
    q = (z.b + (double) H) - (double) R;
    r = (z.c + z.f) / 2D;
    B = d6 != d1 || d8 != d3;
    C = d7 != d2;
    A = d7 != d2 && d7 < 0.0D;
    D = B || C;
    a(d2, A);
    if (d6 != d1) {
      s = 0.0D;
    }
    if (d7 != d2) {
      t = 0.0D;
    }
    if (d8 != d3) {
      u = 0.0D;
    }
    double d11 = p - d4;
    double d13 = r - d5;

    if (M && !flag) {
      L += (double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D;
      int k3 = MathHelper.b(p);
      int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H);
      int l1 = MathHelper.b(r);
      int i3 = l.a(k3, i4, l1);

      if (L > (float) b && i3 > 0) {
        b++;
        StepSound stepsound = Block.m[i3].bq;

        if (l.a(k3, i4 + 1, l1) == Block.aS.bh) {
          stepsound = Block.aS.bq;
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        } else if (!Block.m[i3].bs.d()) {
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        }
        Block.m[i3].b(l, k3, i4, l1, this);
      }
    }
    int l3 = MathHelper.b(z.a);
    int j4 = MathHelper.b(z.b);
    int i2 = MathHelper.b(z.c);
    int j3 = MathHelper.b(z.d);
    int k4 = MathHelper.b(z.e);
    int l4 = MathHelper.b(z.f);

    for (int i5 = l3; i5 <= j3; i5++) {
      for (int j5 = j4; j5 <= k4; j5++) {
        for (int k5 = i2; k5 <= l4; k5++) {
          int l5 = l.a(i5, j5, k5);

          if (l5 > 0) {
            Block.m[l5].a(l, i5, j5, k5, this);
          }
        }
      }
    }

    R *= 0.4F;
    boolean flag2 = r();

    if (l.c(z)) {
      b(1);
      if (!flag2) {
        Z++;
        if (Z == 0) {
          Z = 300;
        }
      }
    } else if (Z <= 0) {
      Z = -Y;
    }
    if (flag2 && Z > 0) {
      l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F);
      Z = -Y;
    }
  }
  private void g(World world, int i, int j, int k) {
    boolean flag = world.getData(i, j, k) == 1;
    boolean flag1 = false;
    float f = 0.125F;
    List list = null;

    if (this.a == EnumMobType.EVERYTHING) {
      list =
          world.b(
              (Entity) null,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.MOBS) {
      list =
          world.a(
              EntityLiving.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.PLAYERS) {
      list =
          world.a(
              EntityHuman.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (list.size() > 0) {
      flag1 = true;
    }

    // CraftBukkit start - Interact Pressure Plate
    org.bukkit.World bworld = world.getWorld();
    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();

    if (flag != flag1) {
      if (flag1) {
        for (Object object : list) {
          if (object != null) {
            org.bukkit.event.Cancellable cancellable;

            if (object instanceof EntityHuman) {
              cancellable =
                  CraftEventFactory.callPlayerInteractEvent(
                      (EntityHuman) object,
                      org.bukkit.event.block.Action.PHYSICAL,
                      i,
                      j,
                      k,
                      -1,
                      null);
            } else if (object instanceof Entity) {
              cancellable =
                  new EntityInteractEvent(
                      ((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
              manager.callEvent((EntityInteractEvent) cancellable);
            } else {
              continue;
            }
            if (cancellable.isCancelled()) {
              return;
            }
          }
        }
      }

      BlockRedstoneEvent eventRedstone =
          new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
      manager.callEvent(eventRedstone);

      flag1 = eventRedstone.getNewCurrent() > 0;
    }
    // CraftBukkit end

    if (flag1 && !flag) {
      world.setData(i, j, k, 1);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag1 && flag) {
      world.setData(i, j, k, 0);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag1) {
      world.c(i, j, k, this.id, this.d());
    }
  }
Exemple #10
0
  public void a() {
    float f = this.size;
    byte b0 = 16;

    int i;
    int j;
    int k;
    double d0;
    double d1;
    double d2;

    for (i = 0; i < b0; ++i) {
      for (j = 0; j < b0; ++j) {
        for (k = 0; k < b0; ++k) {
          if (i == 0 || i == b0 - 1 || j == 0 || j == b0 - 1 || k == 0 || k == b0 - 1) {
            double d3 = (double) ((float) i / ((float) b0 - 1.0F) * 2.0F - 1.0F);
            double d4 = (double) ((float) j / ((float) b0 - 1.0F) * 2.0F - 1.0F);
            double d5 = (double) ((float) k / ((float) b0 - 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.size * (0.7F + this.world.random.nextFloat() * 0.6F);

            d0 = this.posX;
            d1 = this.posY;
            d2 = this.posZ;

            for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
              int l = MathHelper.floor(d0);
              int i1 = MathHelper.floor(d1);
              int j1 = MathHelper.floor(d2);
              int k1 = this.world.getTypeId(l, i1, j1);

              if (k1 > 0) {
                f1 -= (Block.byId[k1].a(this.source) + 0.3F) * f2;
              }

              if (f1 > 0.0F) {
                this.g.add(new ChunkPosition(l, i1, j1));
              }

              d0 += d3 * (double) f2;
              d1 += d4 * (double) f2;
              d2 += d5 * (double) f2;
            }
          }
        }
      }
    }

    this.size *= 2.0F;
    i = MathHelper.floor(this.posX - (double) this.size - 1.0D);
    j = MathHelper.floor(this.posX + (double) this.size + 1.0D);
    k = MathHelper.floor(this.posY - (double) this.size - 1.0D);
    int l1 = MathHelper.floor(this.posY + (double) this.size + 1.0D);
    int i2 = MathHelper.floor(this.posZ - (double) this.size - 1.0D);
    int j2 = MathHelper.floor(this.posZ + (double) this.size + 1.0D);
    List list =
        this.world.b(
            this.source,
            AxisAlignedBB.b(
                (double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
    Vec3D vec3d = Vec3D.create(this.posX, this.posY, this.posZ);

    for (int k2 = 0; k2 < list.size(); ++k2) {
      Entity entity = (Entity) list.get(k2);
      double d7 = entity.e(this.posX, this.posY, this.posZ) / (double) this.size;

      if (d7 <= 1.0D) {
        d0 = entity.locX - this.posX;
        d1 = entity.locY - this.posY;
        d2 = entity.locZ - this.posZ;
        double d8 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);

        d0 /= d8;
        d1 /= d8;
        d2 /= d8;
        double d9 = (double) this.world.a(vec3d, entity.boundingBox);
        double d10 = (1.0D - d7) * d9;

        // CraftBukkit start - explosion damage hook
        CraftServer server = ((WorldServer) this.world).getServer();
        org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
        DamageCause damageType;
        int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D);

        if (damagee == null) {
          // nothing was hurt
        } else if (this.source == null) { // Block explosion
          // TODO: get the x/y/z of the tnt block?
          // does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
          damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;

          EntityDamageByBlockEvent event =
              new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
          server.getPluginManager().callEvent(event);

          if (!event.isCancelled()) {
            entity.damageEntity(this.source, event.getDamage());
            entity.motX += d0 * d10;
            entity.motY += d1 * d10;
            entity.motZ += d2 * d10;
          }
        } else {
          org.bukkit.entity.Entity damager = this.source.getBukkitEntity();
          damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;

          EntityDamageByEntityEvent event =
              new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
          server.getPluginManager().callEvent(event);

          if (!event.isCancelled()) {
            entity.damageEntity(this.source, event.getDamage());

            entity.motX += d0 * d10;
            entity.motY += d1 * d10;
            entity.motZ += d2 * d10;
          }
        }
        // CraftBukkit end
      }
    }

    this.size = f;
    ArrayList arraylist = new ArrayList();

    arraylist.addAll(this.g);
    if (this.a) {
      for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
        ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
        int i3 = chunkposition.x;
        int j3 = chunkposition.y;
        int k3 = chunkposition.z;
        int l3 = this.world.getTypeId(i3, j3, k3);
        int i4 = this.world.getTypeId(i3, j3 - 1, k3);

        if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) {
          this.world.setTypeId(i3, j3, k3, Block.FIRE.id);
        }
      }
    }
  }
Exemple #11
0
  public EnumBedResult a(int i, int j, int k) {
    if (!this.world.isStatic) {
      if (this.isSleeping() || !this.isAlive()) {
        return EnumBedResult.OTHER_PROBLEM;
      }

      if (!this.world.worldProvider.d()) {
        return EnumBedResult.NOT_POSSIBLE_HERE;
      }

      if (this.world.e()) {
        return EnumBedResult.NOT_POSSIBLE_NOW;
      }

      if (Math.abs(this.locX - (double) i) > 3.0D
          || Math.abs(this.locY - (double) j) > 2.0D
          || Math.abs(this.locZ - (double) k) > 3.0D) {
        return EnumBedResult.TOO_FAR_AWAY;
      }

      double d0 = 8.0D;
      double d1 = 5.0D;
      List list =
          this.world.a(
              EntityMonster.class,
              AxisAlignedBB.b(
                  (double) i - d0,
                  (double) j - d1,
                  (double) k - d0,
                  (double) i + d0,
                  (double) j + d1,
                  (double) k + d0));

      if (!list.isEmpty()) {
        return EnumBedResult.NOT_SAFE;
      }
    }

    this.b(0.2F, 0.2F);
    this.height = 0.2F;
    if (this.world.isLoaded(i, j, k)) {
      int l = this.world.getData(i, j, k);
      int i1 = BlockBed.b(l);
      float f = 0.5F;
      float f1 = 0.5F;

      switch (i1) {
        case 0:
          f1 = 0.9F;
          break;

        case 1:
          f = 0.1F;
          break;

        case 2:
          f1 = 0.1F;
          break;

        case 3:
          f = 0.9F;
      }

      this.c(i1);
      this.setPosition(
          (double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1));
    } else {
      this.setPosition(
          (double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F));
    }

    this.sleeping = true;
    this.sleepTicks = 0;
    this.F = new ChunkCoordinates(i, j, k);
    this.motX = this.motZ = this.motY = 0.0D;
    if (!this.world.isStatic) {
      this.world.everyoneSleeping();
    }

    return EnumBedResult.OK;
  }