--- title: "Selection API - BuildPrint wiki" description: "Read and change the player's selection, and capture part of the world as blueprint data." url: https://voxelsprout.com/buildprint/wiki/selection-api --- [BuildPrint](https://voxelsprout.com/buildprint) [Wiki](https://voxelsprout.com/buildprint/wiki)Selection API # Selection API Read and change the player's selection, and capture part of the world as blueprint data. The selection is the set of boxes the editor's Select tool and the `/buildprint pos1` commands make. Changes show at once, in the editor and outside it. From BuildPrint **0.1.19**. A box is `int[] {minX, minY, minZ, maxX, maxY, maxZ}` in world blocks, inclusive. Several boxes are one `int[]` with 6 numbers per box. ## Change the selection ```java BuildprintSelection.clear(); int index = BuildprintSelection.add(new int[]{0, 64, 0, 15, 80, 15}); int[] boxes = BuildprintSelection.regions(); BuildprintSelection.remove(index); ``` ## Capture part of the world A capture is what saving the selection would write, as [blueprint data](https://voxelsprout.com/buildprint/wiki/placements-api#blueprint-data) and without a file. It keeps block entities, entities and each box as a region. ```java BuildprintSelection.capture("mymod", data -> { if (data == null) return; // the player left the world in between int[] origin = (int[]) data.get("origin"); // world block of the first cell boolean complete = (Boolean) data.get("complete"); }); // Or other boxes; the selection stays as it is. BuildprintSelection.captureBoxes("mymod", new int[]{0, 64, 0, 7, 70, 7}, data -> { }); ``` ## Good to know * In single-player the capture comes from the world on the built-in server, so it has everything, container contents too. * On a server it has what the game sends players. Container contents are only there for containers the player opened this session. `unseenContainers` says how many were not. * `complete` is false when part of it was not loaded and came out as air. `missingChunks` says how many chunks. * The callback runs on the client thread: at once on a server, a moment later in single-player. * A server can turn off making schematics with BuildPrint Policy. `capture` then returns false and does not call back. * Captures over 67,108,864 blocks call back with null. ## Reference | BuildprintSelection | What it does | | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------- | | isAvailable() | In a world. | | regions() / activeRegion() | The boxes in order, and the index of the active one, or -1. | | add(int\[\] box) | Add a box, corners in any order, and make it active. Returns its index. | | remove(int index) / clear() | Remove one box, or all of them. | | capture(String owner, Consumer> done) | Capture the selection. | | captureBoxes(String owner, int\[\] boxes, Consumer> done) | Capture these boxes instead. | [Previous Library API](https://voxelsprout.com/buildprint/wiki/library-api) [Next Rules API](https://voxelsprout.com/buildprint/wiki/rules-api) Something missing or wrong on this page? Say so on [Discord](https://discord.gg/CvdkGbEW4y).