/** * Find needed chunks in the region. * * @param region */ private void findNeededChunks(Region region) { // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment for (Vector pos : region) { BlockVector2D chunkPos = ChunkStore.toChunk(pos); // Unidentified chunk if (!neededChunks.containsKey(chunkPos)) { neededChunks.put(chunkPos, new ArrayList<Vector>()); } neededChunks.get(chunkPos).add(pos); } }
/** * Find needed chunks in the cuboid of the region. * * @param region */ private void findNeededCuboidChunks(Region region) { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { Vector pos = new Vector(x, y, z); BlockVector2D chunkPos = ChunkStore.toChunk(pos); // Unidentified chunk if (!neededChunks.containsKey(chunkPos)) { neededChunks.put(chunkPos, new ArrayList<Vector>()); } neededChunks.get(chunkPos).add(pos); } } } }