Exemplo n.º 1
0
  public boolean actPrimary(
      ServerInterface server,
      LocalConfiguration config,
      LocalPlayer player,
      LocalSession session,
      WorldVector clicked) {

    BlockBag bag = session.getBlockBag(player);

    LocalWorld world = clicked.getWorld();
    EditSession editSession =
        WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);

    try {
      editSession.setBlock(clicked, targetBlock);
    } catch (MaxChangedBlocksException e) {
    } finally {
      if (bag != null) {
        bag.flushChanges();
      }
      session.remember(editSession);
    }

    return true;
  }
Exemplo n.º 2
0
  /**
   * Places the blocks in a position from the minimum corner.
   *
   * @param editSession
   * @param pos
   * @param noAir
   * @throws MaxChangedBlocksException
   */
  public void place(EditSession editSession, Vector pos, boolean noAir)
      throws MaxChangedBlocksException {
    for (int x = 0; x < size.getBlockX(); ++x) {
      for (int y = 0; y < size.getBlockY(); ++y) {
        for (int z = 0; z < size.getBlockZ(); ++z) {
          if (noAir && data[x][y][z].isAir()) {
            continue;
          }

          editSession.setBlock(new Vector(x, y, z).add(pos), data[x][y][z]);
        }
      }
    }
  }