Ejemplo n.º 1
0
  public boolean y() {
    int i1 = MathHelper.b(p);
    int j1 = MathHelper.b(q + (double) s());
    int k1 = MathHelper.b(r);

    return l.d(i1, j1, k1);
  }
Ejemplo n.º 2
0
  public void d(World world, BlockPosition blockposition) {
    if (!world.worldProvider.o()) {
      IBlockData iblockdata = world.getType(blockposition);
      int i = world.b(EnumSkyBlock.SKY, blockposition) - world.ab();
      float f = world.d(1.0F);
      float f1 = f < 3.1415927F ? 0.0F : 6.2831855F;

      f += (f1 - f) * 0.2F;
      i = Math.round((float) i * MathHelper.cos(f));
      i = MathHelper.clamp(i, 0, 15);
      if (this.b) {
        i = 15 - i;
      }

      if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {
        i =
            org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(
                    world,
                    blockposition.getX(),
                    blockposition.getY(),
                    blockposition.getZ(),
                    ((Integer) iblockdata.get(POWER)),
                    i)
                .getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
        world.setTypeAndData(
            blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
      }
    }
  }
Ejemplo n.º 3
0
  public void remove(World world, int i, int j, int k, int l, int i1) {
    byte b0 = 1;
    int j1 = b0 + 1;

    if (world.d(i - j1, j - j1, k - j1, i + j1, j + j1, k + j1)) {
      for (int k1 = -b0; k1 <= b0; ++k1) {
        for (int l1 = -b0; l1 <= b0; ++l1) {
          for (int i2 = -b0; i2 <= b0; ++i2) {
            int j2 = world.getTypeId(i + k1, j + l1, k + i2);

            if (Block.byId[j2] != null) {
              Block.byId[j2].beginLeavesDecay(world, i + k1, j + l1, k + i2);
            }
          }
        }
      }
    }
  }
  public ItemStack b(IBlockSource iblocksource, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.j_(iblocksource.h());
    World world = iblocksource.k();
    double d0 = iblocksource.a() + (double) ((float) enumfacing.c() * 1.125F);
    double d1 = iblocksource.b() + (double) ((float) enumfacing.d() * 1.125F);
    double d2 = iblocksource.c() + (double) ((float) enumfacing.e() * 1.125F);
    int i0 = iblocksource.d() + enumfacing.c();
    int i1 = iblocksource.e() + enumfacing.d();
    int i2 = iblocksource.f() + enumfacing.e();
    int i3 = world.a(i0, i1, i2);
    double d3;

    if (BlockRailBase.d_(i3)) {
      d3 = 0.0D;
    } else {
      if (i3 != 0 || !BlockRailBase.d_(world.a(i0, i1 - 1, i2))) {
        return this.b.a(iblocksource, itemstack);
      }

      d3 = -1.0D;
    }

    EntityMinecart entityminecart =
        EntityMinecart.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.b()).a);

    // CanaryMod: Dispense
    DispenseHook hook =
        new DispenseHook(
            ((TileEntityDispenser) iblocksource.j()).getCanaryDispenser(),
            entityminecart.getCanaryEntity());

    Canary.hooks().callHook(hook);
    if (!hook.isCanceled()) {
      world.d((Entity) entityminecart);
      itemstack.a(1);
    }
    //
    return itemstack;
  }
Ejemplo n.º 5
0
  public void a(World world, int i, int j, int k, int l) {
    int i1 = world.getData(i, j, k);

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

      if (l > 0 && Block.byId[l].c()) {
        this.a(world, i, j - 1, k, l);
      }
    } else {
      boolean flag = false;

      if (world.getTypeId(i, j + 1, k) != this.id) {
        world.e(i, j, k, 0);
        flag = true;
      }

      if (!world.d(i, j - 1, k)) {
        world.e(i, j, k, 0);
        flag = true;
        if (world.getTypeId(i, j + 1, k) == this.id) {
          world.e(i, j + 1, k, 0);
        }
      }

      if (flag) {
        if (!world.isStatic) {
          this.a_(world, i, j, k, i1);
        }
      } else if (l > 0 && Block.byId[l].c()) {
        boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k);

        this.a(world, i, j, k, flag1);
      }
    }
  }
Ejemplo n.º 6
0
  private void a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getData(i, j, k);
    int l1 = 0;

    this.a = false;
    boolean flag = world.isBlockIndirectlyPowered(i, j, k);

    this.a = true;

    if (flag) {
      l1 = 15;
    } else {
      for (int i2 = 0; i2 < 4; i2++) {
        int j2 = i;
        int k2 = k;
        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          j2++;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          k2++;
        }

        if ((j2 != l) || (j != i1) || (k2 != j1)) {
          l1 = getPower(world, j2, j, k2, l1);
        }

        if ((world.s(j2, j, k2)) && (!world.s(i, j + 1, k))) {
          if ((j2 != l) || (j + 1 != i1) || (k2 != j1)) l1 = getPower(world, j2, j + 1, k2, l1);
        } else if ((!world.s(j2, j, k2)) && ((j2 != l) || (j - 1 != i1) || (k2 != j1))) {
          l1 = getPower(world, j2, j - 1, k2, l1);
        }
      }

      if (l1 > 0) l1--;
      else {
        l1 = 0;
      }
    }

    if (k1 != l1) {
      BlockRedstoneEvent event =
          new BlockRedstoneEvent(world.getWorld().getBlockAt(i, j, k), k1, l1);
      world.getServer().getPluginManager().callEvent(event);

      l1 = event.getNewCurrent();
    }

    if (k1 != l1) {
      world.suppressPhysics = true;
      world.setData(i, j, k, l1);
      world.d(i, j, k, i, j, k);
      world.suppressPhysics = false;

      for (int i2 = 0; i2 < 4; i2++) {
        int j2 = i;
        int k2 = k;
        int l2 = j - 1;

        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          j2++;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          k2++;
        }

        if (world.s(j2, j, k2)) {
          l2 += 2;
        }

        boolean flag1 = false;
        int i3 = getPower(world, j2, j, k2, -1);

        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          l1--;
        }

        if ((i3 >= 0) && (i3 != l1)) {
          a(world, j2, j, k2, i, j, k);
        }

        i3 = getPower(world, j2, l2, k2, -1);
        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          l1--;
        }

        if ((i3 >= 0) && (i3 != l1)) {
          a(world, j2, l2, k2, i, j, k);
        }
      }

      if ((k1 < l1) || (l1 == 0)) {
        this.b.add(new ChunkPosition(i, j, k));
        this.b.add(new ChunkPosition(i - 1, j, k));
        this.b.add(new ChunkPosition(i + 1, j, k));
        this.b.add(new ChunkPosition(i, j - 1, k));
        this.b.add(new ChunkPosition(i, j + 1, k));
        this.b.add(new ChunkPosition(i, j, k - 1));
        this.b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }
Ejemplo n.º 7
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);
      }
    }
  }
Ejemplo n.º 8
0
  /** Ticks the block if it's been scheduled */
  public void b(World var1, int var2, int var3, int var4, Random var5) {
    if (!var1.isStatic) {
      int var6 = var1.getData(var2, var3, var4);

      if ((var6 & 8) != 0 && (var6 & 4) == 0) {
        byte var7 = 4;
        int var8 = var7 + 1;
        byte var9 = 32;
        int var10 = var9 * var9;
        int var11 = var9 / 2;

        if (this.b == null) {
          this.b = new int[var9 * var9 * var9];
        }

        int var12;

        if (var1.d(var2 - var8, var3 - var8, var4 - var8, var2 + var8, var3 + var8, var4 + var8)) {
          int var13;
          int var14;
          int var15;

          for (var12 = -var7; var12 <= var7; ++var12) {
            for (var13 = -var7; var13 <= var7; ++var13) {
              for (var14 = -var7; var14 <= var7; ++var14) {
                var15 = var1.getTypeId(var2 + var12, var3 + var13, var4 + var14);
                Block var16 = Block.byId[var15];

                if (var16 != null
                    && var16.canSustainLeaves(var1, var2 + var12, var3 + var13, var4 + var14)) {
                  this.b[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = 0;
                } else if (var16 != null
                    && var16.isLeaves(var1, var2 + var12, var3 + var13, var4 + var14)) {
                  this.b[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = -2;
                } else {
                  this.b[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = -1;
                }
              }
            }
          }

          for (var12 = 1; var12 <= 4; ++var12) {
            for (var13 = -var7; var13 <= var7; ++var13) {
              for (var14 = -var7; var14 <= var7; ++var14) {
                for (var15 = -var7; var15 <= var7; ++var15) {
                  if (this.b[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11]
                      == var12 - 1) {
                    if (this.b[(var13 + var11 - 1) * var10 + (var14 + var11) * var9 + var15 + var11]
                        == -2) {
                      this.b[(var13 + var11 - 1) * var10 + (var14 + var11) * var9 + var15 + var11] =
                          var12;
                    }

                    if (this.b[(var13 + var11 + 1) * var10 + (var14 + var11) * var9 + var15 + var11]
                        == -2) {
                      this.b[(var13 + var11 + 1) * var10 + (var14 + var11) * var9 + var15 + var11] =
                          var12;
                    }

                    if (this.b[(var13 + var11) * var10 + (var14 + var11 - 1) * var9 + var15 + var11]
                        == -2) {
                      this.b[(var13 + var11) * var10 + (var14 + var11 - 1) * var9 + var15 + var11] =
                          var12;
                    }

                    if (this.b[(var13 + var11) * var10 + (var14 + var11 + 1) * var9 + var15 + var11]
                        == -2) {
                      this.b[(var13 + var11) * var10 + (var14 + var11 + 1) * var9 + var15 + var11] =
                          var12;
                    }

                    if (this.b[
                            (var13 + var11) * var10 + (var14 + var11) * var9 + (var15 + var11 - 1)]
                        == -2) {
                      this.b[
                              (var13 + var11) * var10
                                  + (var14 + var11) * var9
                                  + (var15 + var11 - 1)] =
                          var12;
                    }

                    if (this.b[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11 + 1]
                        == -2) {
                      this.b[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11 + 1] =
                          var12;
                    }
                  }
                }
              }
            }
          }
        }

        var12 = this.b[var11 * var10 + var11 * var9 + var11];

        if (var12 >= 0) {
          var1.setRawData(var2, var3, var4, var6 & -9);
        } else {
          this.l(var1, var2, var3, var4);
        }
      }
    }
  }
Ejemplo n.º 9
0
 public boolean a(World world, int i, int j, int k) {
   return j >= 127
       ? false
       : world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k);
 }