public void remove(World world, int i, int j, int k, int l, int i1) {
    super.remove(world, i, j, k, l, i1);
    if (!world.isStatic) {
      world.applyPhysics(i, j + 1, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.applyPhysics(i + 1, j, k, this.id);
      world.applyPhysics(i - 1, j, k, this.id);
      world.applyPhysics(i, j, k + 1, this.id);
      world.applyPhysics(i, j, k - 1, this.id);
      l(world, i, j, k);
      n(world, i - 1, j, k);
      n(world, i + 1, j, k);
      n(world, i, j, k - 1);
      n(world, i, j, k + 1);
      if (world.s(i - 1, j, k)) n(world, i - 1, j + 1, k);
      else {
        n(world, i - 1, j - 1, k);
      }

      if (world.s(i + 1, j, k)) n(world, i + 1, j + 1, k);
      else {
        n(world, i + 1, j - 1, k);
      }

      if (world.s(i, j, k - 1)) n(world, i, j + 1, k - 1);
      else {
        n(world, i, j - 1, k - 1);
      }

      if (world.s(i, j, k + 1)) n(world, i, j + 1, k + 1);
      else n(world, i, j - 1, k + 1);
    }
  }
Beispiel #2
0
  public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (((Boolean) iblockdata.get(POWERED)).booleanValue()) {
      world.applyPhysics(blockposition, this);
      EnumDirection enumdirection = ((EnumLeverPosition) iblockdata.get(FACING)).c();

      world.applyPhysics(blockposition.shift(enumdirection.opposite()), this);
    }
    super.remove(world, blockposition, iblockdata);
  }
Beispiel #3
0
  public void remove(World world, int i, int j, int k) {
    int l = world.getData(i, j, k);

    if (l > 0) {
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
    }

    super.remove(world, i, j, k);
  }
 private void n(World world, int i, int j, int k) {
   if (world.getTypeId(i, j, k) == this.id) {
     world.applyPhysics(i, j, k, this.id);
     world.applyPhysics(i - 1, j, k, this.id);
     world.applyPhysics(i + 1, j, k, this.id);
     world.applyPhysics(i, j, k - 1, this.id);
     world.applyPhysics(i, j, k + 1, this.id);
     world.applyPhysics(i, j - 1, k, this.id);
     world.applyPhysics(i, j + 1, k, this.id);
   }
 }
  public void onPlace(World world, int i, int j, int k) {
    if (world.suppressPhysics) return;
    super.onPlace(world, i, j, k);
    if (!world.isStatic) {
      l(world, i, j, k);
      world.applyPhysics(i, j + 1, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      n(world, i - 1, j, k);
      n(world, i + 1, j, k);
      n(world, i, j, k - 1);
      n(world, i, j, k + 1);
      if (world.s(i - 1, j, k)) n(world, i - 1, j + 1, k);
      else {
        n(world, i - 1, j - 1, k);
      }

      if (world.s(i + 1, j, k)) n(world, i + 1, j + 1, k);
      else {
        n(world, i + 1, j - 1, k);
      }

      if (world.s(i, j, k - 1)) n(world, i, j + 1, k - 1);
      else {
        n(world, i, j - 1, k - 1);
      }

      if (world.s(i, j, k + 1)) n(world, i, j + 1, k + 1);
      else n(world, i, j - 1, k + 1);
    }
  }
  private void l(World world, int i, int j, int k) {
    this.a(world, i, j, k, i, j, k);
    ArrayList arraylist = new ArrayList(this.b);

    this.b.clear();

    for (int l = 0; l < arraylist.size(); ++l) {
      ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);

      world.applyPhysics(chunkposition.x, chunkposition.y, chunkposition.z, this.id);
    }
  }
Beispiel #7
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (world.isClientSide) {
      return true;
    }
    boolean powered = ((Boolean) iblockdata.get(POWERED)).booleanValue();
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    int old = powered ? 15 : 0;
    int current = !powered ? 15 : 0;

    BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
    world.getServer().getPluginManager().callEvent(eventRedstone);
    if ((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1)) {
      return true;
    }
    iblockdata = iblockdata.a(POWERED);
    world.setTypeAndData(blockposition, iblockdata, 3);
    world.makeSound(
        blockposition.getX() + 0.5D,
        blockposition.getY() + 0.5D,
        blockposition.getZ() + 0.5D,
        "random.click",
        0.3F,
        ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0.6F : 0.5F);
    world.applyPhysics(blockposition, this);
    EnumDirection enumdirection1 = ((EnumLeverPosition) iblockdata.get(FACING)).c();

    world.applyPhysics(blockposition.shift(enumdirection1.opposite()), this);
    return true;
  }
  private void l(World world, int i, int j, int k) {
    a(world, i, j, k, i, j, k);
    ArrayList arraylist = new ArrayList(this.b);

    this.b.clear();
    Iterator iterator = arraylist.iterator();

    while (iterator.hasNext()) {
      ChunkPosition chunkposition = (ChunkPosition) iterator.next();

      world.applyPhysics(chunkposition.x, chunkposition.y, chunkposition.z, this.id);
    }
  }
  public void onPlace(World world, int i, int j, int k) {
    if (world.suppressPhysics) return; // CraftBukkit
    super.onPlace(world, i, j, k);
    if (!world.isStatic) {
      this.l(world, i, j, k);
      world.applyPhysics(i, j + 1, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      this.n(world, i - 1, j, k);
      this.n(world, i + 1, j, k);
      this.n(world, i, j, k - 1);
      this.n(world, i, j, k + 1);
      if (world.t(i - 1, j, k)) {
        this.n(world, i - 1, j + 1, k);
      } else {
        this.n(world, i - 1, j - 1, k);
      }

      if (world.t(i + 1, j, k)) {
        this.n(world, i + 1, j + 1, k);
      } else {
        this.n(world, i + 1, j - 1, k);
      }

      if (world.t(i, j, k - 1)) {
        this.n(world, i, j + 1, k - 1);
      } else {
        this.n(world, i, j - 1, k - 1);
      }

      if (world.t(i, j, k + 1)) {
        this.n(world, i, j + 1, k + 1);
      } else {
        this.n(world, i, j - 1, k + 1);
      }
    }
  }
Beispiel #10
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());
    }
  }
Beispiel #11
0
  public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
    org.bukkit.World bworld = world.getWorld();
    Server server = world.getServer();
    org.bukkit.block.Block source =
        bworld == null
            ? null
            : bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

    int i = ((Integer) iblockdata.get(LEVEL)).intValue();
    byte b0 = 1;
    if ((this.material == Material.LAVA) && (!world.worldProvider.n())) {
      b0 = 2;
    }
    int j = a(world);
    if (i > 0) {
      int l = -100;

      this.a = 0;
      EnumDirection enumdirection;
      for (Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
          iterator.hasNext();
          l = a(world, blockposition.shift(enumdirection), l)) {
        enumdirection = (EnumDirection) iterator.next();
      }
      int i1 = l + b0;
      if ((i1 >= 8) || (l < 0)) {
        i1 = -1;
      }
      if (e(world, blockposition.up()) >= 0) {
        int k = e(world, blockposition.up());
        if (k >= 8) {
          i1 = k;
        } else {
          i1 = k + 8;
        }
      }
      if ((this.a >= 2) && (this.material == Material.WATER)) {
        IBlockData iblockdata1 = world.getType(blockposition.down());
        if (iblockdata1.getBlock().getMaterial().isBuildable()) {
          i1 = 0;
        } else if ((iblockdata1.getBlock().getMaterial() == this.material)
            && (((Integer) iblockdata1.get(LEVEL)).intValue() == 0)) {
          i1 = 0;
        }
      }
      if ((this.material == Material.LAVA)
          && (i < 8)
          && (i1 < 8)
          && (i1 > i)
          && (random.nextInt(4) != 0)) {
        j *= 4;
      }
      if (i1 == i) {
        f(world, blockposition, iblockdata);
      } else {
        i = i1;
        if (i1 < 0) {
          world.setAir(blockposition);
        } else {
          iblockdata = iblockdata.set(LEVEL, Integer.valueOf(i1));
          world.setTypeAndData(blockposition, iblockdata, 2);
          world.a(blockposition, this, j);
          world.applyPhysics(blockposition, this);
        }
      }
    } else {
      f(world, blockposition, iblockdata);
    }
    IBlockData iblockdata2 = world.getType(blockposition.down());
    if (h(world, blockposition.down(), iblockdata2)) {
      BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
      if (server != null) {
        server.getPluginManager().callEvent(event);
      }
      if (!event.isCancelled()) {
        if ((this.material == Material.LAVA)
            && (world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER)) {
          world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
          fizz(world, blockposition.down());
          return;
        }
        if (i >= 8) {
          flow(world, blockposition.down(), iblockdata2, i);
        } else {
          flow(world, blockposition.down(), iblockdata2, i + 8);
        }
      }
    } else if ((i >= 0) && ((i == 0) || (g(world, blockposition.down(), iblockdata2)))) {
      Set set = f(world, blockposition);

      int k = i + b0;
      if (i >= 8) {
        k = 1;
      }
      if (k >= 8) {
        return;
      }
      Iterator iterator1 = set.iterator();
      while (iterator1.hasNext()) {
        EnumDirection enumdirection1 = (EnumDirection) iterator1.next();

        BlockFromToEvent event =
            new BlockFromToEvent(source, CraftBlock.notchToBlockFace(enumdirection1));
        if (server != null) {
          server.getPluginManager().callEvent(event);
        }
        if (!event.isCancelled()) {
          flow(
              world,
              blockposition.shift(enumdirection1),
              world.getType(blockposition.shift(enumdirection1)),
              k);
        }
      }
    }
  }