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

    EditSession editSession = session.createEditSession(player);

    try {
      boolean successful = false;

      for (int i = 0; i < 10; i++) {
        if (gen.generate(editSession, clicked.add(0, 1, 0))) {
          successful = true;
          break;
        }
      }

      if (!successful) {
        player.printError("A tree can't go there.");
      }
    } catch (MaxChangedBlocksException e) {
      player.printError("Max. blocks changed reached.");
    } finally {
      session.remember(editSession);
    }

    return true;
  }
  /**
   * Adds a position to be used a source.
   *
   * @return
   */
  @Override
  public void addSourcePosition(WorldVector arg0) {
    // int ox = pos.getBlockX();
    // int oy = pos.getBlockY();
    // int oz = pos.getBlockZ();

    for (int x = -3; x <= 3; x++) {
      for (int y = -3; y <= 3; y++) {
        for (int z = -3; z <= 3; z++) {
          Vector cur = arg0.add(x, y, z);
          addSingleSourcePosition(new WorldVector(arg0.getWorld(), cur));
        }
      }
    }
  }
Esempio n. 3
0
  @Override
  public boolean act(
      ServerInterface server,
      LocalConfiguration config,
      LocalPlayer player,
      LocalSession session,
      WorldVector clicked) {

    LocalWorld world = clicked.getWorld();
    EditSession editSession = new EditSession(server, world, session.getBlockChangeLimit());

    try {
      editSession.makePineTree(clicked.add(0, 1, 0));
    } catch (MaxChangedBlocksException e) {
      player.printError("Max blocks change limit reached.");
    } finally {
      session.remember(editSession);
    }

    return true;
  }