Esempio n. 1
0
  public boolean a(World world, int i, int j, int k) {
    int l = world.a(i, j - 1, k);

    if (l == 0 || !Block.m[l].a()) {
      return false;
    } else {
      return world.c(i, j - 1, k).c();
    }
  }
  public void doPhysics(World world, int i, int j, int k, int l) {
    if (l > 0 && Block.byId[l].isPowerSource()) {
      boolean flag =
          world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k);

      if (flag) {
        world.c(i, j, k, this.id, this.d());
      }
    }
  }
Esempio n. 3
0
 public boolean a(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (world.a(i, j, k) == Block.aY.bi && world.b(i, j, k) == 0) {
     world.c(i, j, k, (ba - Item.aY.ba) + 1);
     world.a(a, i, j, k);
     itemstack.a--;
     return true;
   } else {
     return false;
   }
 }
Esempio n. 4
0
  public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
    if (this.material == Material.ORE) {
      return true;
    } else {
      int l = world.getData(i, j, k);

      if ((l & 8) != 0) {
        if (world.getTypeId(i, j - 1, k) == this.id) {
          this.a(world, i, j - 1, k, entityhuman);
        }

        return true;
      } else {
        if (world.getTypeId(i, j + 1, k) == this.id) {
          world.c(i, j + 1, k, (l ^ 4) + 8);
        }

        world.c(i, j, k, l ^ 4);
        world.b(i, j - 1, k, i, j, k);
        if (Math.random() < 0.5D) {
          world.a(
              (double) i + 0.5D,
              (double) j + 0.5D,
              (double) k + 0.5D,
              "random.door_open",
              1.0F,
              world.k.nextFloat() * 0.1F + 0.9F);
        } else {
          world.a(
              (double) i + 0.5D,
              (double) j + 0.5D,
              (double) k + 0.5D,
              "random.door_close",
              1.0F,
              world.k.nextFloat() * 0.1F + 0.9F);
        }

        return true;
      }
    }
  }
Esempio n. 5
0
  public void a(World world, int i, int j, int k, boolean flag) {
    int l = world.getData(i, j, k);

    if ((l & 8) != 0) {
      if (world.getTypeId(i, j - 1, k) == this.id) {
        this.a(world, i, j - 1, k, flag);
      }
    } else {
      boolean flag1 = (world.getData(i, j, k) & 4) > 0;

      if (flag1 != flag) {
        if (world.getTypeId(i, j + 1, k) == this.id) {
          world.c(i, j + 1, k, (l ^ 4) + 8);
        }

        world.c(i, j, k, l ^ 4);
        world.b(i, j - 1, k, i, j, k);
        if (Math.random() < 0.5D) {
          world.a(
              (double) i + 0.5D,
              (double) j + 0.5D,
              (double) k + 0.5D,
              "random.door_open",
              1.0F,
              world.k.nextFloat() * 0.1F + 0.9F);
        } else {
          world.a(
              (double) i + 0.5D,
              (double) j + 0.5D,
              (double) k + 0.5D,
              "random.door_close",
              1.0F,
              world.k.nextFloat() * 0.1F + 0.9F);
        }
      }
    }
  }
Esempio n. 6
0
  private void d(MinecartTrackLogic minecarttracklogic) {
    g.add(((new ChunkPosition(minecarttracklogic.c, minecarttracklogic.d, minecarttracklogic.e))));
    boolean flag = b(c, d, e - 1);
    boolean flag1 = b(c, d, e + 1);
    boolean flag2 = b(c - 1, d, e);
    boolean flag3 = b(c + 1, d, e);
    byte byte0 = -1;

    if (flag || flag1) {
      byte0 = 0;
    }
    if (flag2 || flag3) {
      byte0 = 1;
    }
    if (flag1 && flag3 && !flag && !flag2) {
      byte0 = 6;
    }
    if (flag1 && flag2 && !flag && !flag3) {
      byte0 = 7;
    }
    if (flag && flag2 && !flag1 && !flag3) {
      byte0 = 8;
    }
    if (flag && flag3 && !flag1 && !flag2) {
      byte0 = 9;
    }
    if (byte0 == 0) {
      if (b.a(c, d + 1, e - 1) == a.bi) {
        byte0 = 4;
      }
      if (b.a(c, d + 1, e + 1) == a.bi) {
        byte0 = 5;
      }
    }
    if (byte0 == 1) {
      if (b.a(c + 1, d + 1, e) == a.bi) {
        byte0 = 2;
      }
      if (b.a(c - 1, d + 1, e) == a.bi) {
        byte0 = 3;
      }
    }
    if (byte0 < 0) {
      byte0 = 0;
    }
    b.c(c, d, e, ((int) (byte0)));
  }
Esempio n. 7
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;
    }
  }
Esempio n. 8
0
  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());
    }
  }
Esempio n. 9
0
 public void e(World world, int i, int j, int k) {
   super.e(world, i, j, k);
   if (world.getTypeId(i, j, k) == this.id) {
     world.c(i, j, k, this.id, this.b());
   }
 }
Esempio n. 10
0
  public void a(World world, int i, int j, int k, Random random) {
    int l = this.g(world, i, j, k);
    byte b0 = 1;

    if (this.material == Material.LAVA && !world.m.d) {
      b0 = 2;
    }

    boolean flag = true;
    int i1;

    if (l > 0) {
      byte b1 = -100;

      this.a = 0;
      int j1 = this.e(world, i - 1, j, k, b1);

      j1 = this.e(world, i + 1, j, k, j1);
      j1 = this.e(world, i, j, k - 1, j1);
      j1 = this.e(world, i, j, k + 1, j1);
      i1 = j1 + b0;
      if (i1 >= 8 || j1 < 0) {
        i1 = -1;
      }

      if (this.g(world, i, j + 1, k) >= 0) {
        int k1 = this.g(world, i, j + 1, k);

        if (k1 >= 8) {
          i1 = k1;
        } else {
          i1 = k1 + 8;
        }
      }

      if (this.a >= 2 && this.material == Material.WATER) {
        if (world.d(i, j - 1, k)) {
          i1 = 0;
        } else if (world.getMaterial(i, j - 1, k) == this.material && world.getData(i, j, k) == 0) {
          i1 = 0;
        }
      }

      if (this.material == Material.LAVA && l < 8 && i1 < 8 && i1 > l && random.nextInt(4) != 0) {
        i1 = l;
        flag = false;
      }

      if (i1 != l) {
        l = i1;
        if (i1 < 0) {
          world.e(i, j, k, 0);
        } else {
          world.c(i, j, k, i1);
          world.c(i, j, k, this.id, this.b());
          world.h(i, j, k, this.id);
        }
      } else if (flag) {
        this.i(world, i, j, k);
      }
    } else {
      this.i(world, i, j, k);
    }

    if (this.l(world, i, j - 1, k)) {
      if (l >= 8) {
        world.b(i, j - 1, k, this.id, l);
      } else {
        world.b(i, j - 1, k, this.id, l + 8);
      }
    } else if (l >= 0 && (l == 0 || this.k(world, i, j - 1, k))) {
      boolean[] aboolean = this.j(world, i, j, k);

      i1 = l + b0;
      if (l >= 8) {
        i1 = 1;
      }

      if (i1 >= 8) {
        return;
      }

      if (aboolean[0]) {
        this.f(world, i - 1, j, k, i1);
      }

      if (aboolean[1]) {
        this.f(world, i + 1, j, k, i1);
      }

      if (aboolean[2]) {
        this.f(world, i, j, k - 1, i1);
      }

      if (aboolean[3]) {
        this.f(world, i, j, k + 1, i1);
      }
    }
  }
Esempio n. 11
0
  public void a(boolean flag) {
    boolean flag1 = c(c, d, e - 1);
    boolean flag2 = c(c, d, e + 1);
    boolean flag3 = c(c - 1, d, e);
    boolean flag4 = c(c + 1, d, e);
    int i = -1;

    if ((flag1 || flag2) && !flag3 && !flag4) {
      i = 0;
    }
    if ((flag3 || flag4) && !flag1 && !flag2) {
      i = 1;
    }
    if (flag2 && flag4 && !flag1 && !flag3) {
      i = 6;
    }
    if (flag2 && flag3 && !flag1 && !flag4) {
      i = 7;
    }
    if (flag1 && flag3 && !flag2 && !flag4) {
      i = 8;
    }
    if (flag1 && flag4 && !flag2 && !flag3) {
      i = 9;
    }
    if (i == -1) {
      if (flag1 || flag2) {
        i = 0;
      }
      if (flag3 || flag4) {
        i = 1;
      }
      if (flag) {
        if (flag2 && flag4) {
          i = 6;
        }
        if (flag3 && flag2) {
          i = 7;
        }
        if (flag4 && flag1) {
          i = 9;
        }
        if (flag1 && flag3) {
          i = 8;
        }
      } else {
        if (flag1 && flag3) {
          i = 8;
        }
        if (flag4 && flag1) {
          i = 9;
        }
        if (flag3 && flag2) {
          i = 7;
        }
        if (flag2 && flag4) {
          i = 6;
        }
      }
    }
    if (i == 0) {
      if (b.a(c, d + 1, e - 1) == a.bi) {
        i = 4;
      }
      if (b.a(c, d + 1, e + 1) == a.bi) {
        i = 5;
      }
    }
    if (i == 1) {
      if (b.a(c + 1, d + 1, e) == a.bi) {
        i = 2;
      }
      if (b.a(c - 1, d + 1, e) == a.bi) {
        i = 3;
      }
    }
    if (i < 0) {
      i = 0;
    }
    f = i;
    a();
    b.c(c, d, e, i);
    for (int j = 0; j < g.size(); j++) {
      MinecartTrackLogic minecarttracklogic = a((ChunkPosition) g.get(j));

      if (minecarttracklogic == null) {
        continue;
      }
      minecarttracklogic.b();
      if (minecarttracklogic.c(this)) {
        minecarttracklogic.d(this);
      }
    }
  }