Example #1
0
  private static void buildCache(String arg) throws Exception {
    System.out.println("Loading map...");

    List<Chunk> chunks = loadChunks(arg);

    Rectangle boundingBox = findBoundingBox(chunks);

    // Convert the chunk bounding box to coordinates bounding box.

    boundingBox =
        new Rectangle(
            boundingBox.getX1() * 16,
            boundingBox.getY1() * 16,
            boundingBox.getX2() * 16,
            boundingBox.getY2() * 16);

    System.out.println(
        "Active bounding box: "
            + boundingBox.getX1()
            + "x"
            + boundingBox.getY1()
            + " "
            + boundingBox.getX2()
            + "x"
            + boundingBox.getY2());

    // Build a map of all blocks located at the target coordinates. We add
    // room to Y.

    System.out.println("Building block cache...");

    BlockMap blockMap = BlockMap.build(chunks, boundingBox, MIN_Y, MAX_Y);

    blockMap.save(new File(CACHE_FILE));
  }