--- title: "Blueprint API - BuildPrint wiki" description: "Let your mod keep a blueprint in BuildPrint, so the builds it makes show up as a build to follow." url: https://voxelsprout.com/buildprint/wiki/blueprints-api --- [BuildPrint](https://voxelsprout.com/buildprint) [Wiki](https://voxelsprout.com/buildprint/wiki)Blueprint API # Blueprint API Let your mod keep a blueprint in BuildPrint, so the builds it makes show up as a build to follow. For a mod that makes builds, such as trees, paths or generated structures, and wants them in BuildPrint as a build to follow instead of placing them in the world. From BuildPrint **0.1.12**. ## How it works * Each owner id gets one blueprint per world and dimension. Every write goes into that same placement and file, also after a restart. * The player cannot turn or flip it, because your blocks sit where you put them in the world. * If the player removes it in BuildPrint, the file stays in their library and the next write starts a new one. * Air in the blueprint is ignored, so the ground around your blocks is not shown as blocks in the way. ## Write blocks Positions are world x, y, z triples, one block state string per position. `minecraft:air` clears a block. The call returns what those blocks were before, which is what you need for undo, or null when it was refused. ```java String why = BuildprintBlueprints.problem("mymod"); if (why != null) { player.displayClientMessage(Component.literal(why), true); // already in the player's language return; } String[] before = BuildprintBlueprints.set("mymod", "My trees", new int[]{10, 64, -3, 10, 65, -3}, new String[]{"minecraft:oak_log[axis=y]", "minecraft:oak_leaves[distance=1,persistent=true,waterlogged=false]"}); ``` The file is written 200 ms after the last change, so a stroke of many writes is one write to disk. Call `flush()` if you need it on disk now. ## Keep your own data The five-argument `set` keeps a string of your own with the blueprint, for example which trees are in it. Pass null to leave it as it was, and read it back with `data(owner)`. ## Without a compile dependency Every call takes plain Java types, so reflection is enough: ```java static Method set; static void bind() { if (!FabricLoader.getInstance().isModLoaded("buildprint")) return; try { Class api = Class.forName("com.buildprint.api.BuildprintBlueprints"); set = api.getMethod("set", String.class, String.class, int[].class, String[].class); } catch (ReflectiveOperationException | LinkageError e) { set = null; // BuildPrint is older than 0.1.12. Nothing to do. } } ``` ## Reference | BuildprintBlueprints | What it does | | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | isAvailable() | In a world, with its placements restored, so a write lands in the right blueprint. | | problem(String owner) | Why set would refuse right now, in the player's language. Null when it would not. | | set(String owner, String displayName, int\[\] xyz, String\[\] states) | Write blocks. Returns what they were before, or null when refused. | | set(String owner, String displayName, int\[\] xyz, String\[\] states, String data) | The same, and keep a string of your own with it. Null leaves it as it was. | | blockCount(String owner) | How many blocks your blueprint holds here. | | data(String owner) | Your string, or null. | | ownerName(String owner) / displayName(String owner) | The names the player sees. | | flush() | Write pending changes to disk now. | [Previous For mod developers](https://voxelsprout.com/buildprint/wiki/api) [Next Placements API](https://voxelsprout.com/buildprint/wiki/placements-api) Something missing or wrong on this page? Say so on [Discord](https://discord.gg/CvdkGbEW4y).