c0de_paint/schematics
How c0de paint is set up, its errors and its examples are in the tab c0de_paint/cpaint: Getting started, Errors, Examples.
The library c0de_paint/schematics reads the schematics that players save with Litematica (.litematic), Create (.nbt, the structure files of Minecraft) and Axiom (.bp, its blueprints) into canvases, and writes canvases as schematics (EXPORT_SCHEMATIC). A program includes it with INCLUDE c0de_paint/schematics, and c0de_paint/cpaint for the canvases.
Where the files are. The mods save schematics in the folder schematics of the game folder of the player (Axiom keeps its blueprints in a folder of its own; copy them into schematics). On a server, that folder is on the computer of the player, so the client of the player who runs the process reads the file and sends it to the server; the process waits on its CALL line meanwhile. EXPORT_SCHEMATIC goes the other way: the server sends the file, and the client saves it. The player must be online and have c0de paint installed (CLIENT_UNAVAILABLE). Every player decides on their own computer whether their client reads and writes files: allowSchematics and allowSchematicWrites in config/c0de_paint-client.properties (both default true; with false, SCHEMATICS_DISABLED). In single player, server and client are the same computer.
Names. A file is a plain name in the folder schematics itself, like "keep.litematic"; subfolders aren't used. Names with /, \ or : or other characters that file names can't have (* ? " < > |), names that start or end with a dot or a space, names that Windows reserves for devices (like "CON.nbt") and names with hidden characters raise INVALID_ARGUMENT. Files that are links aren't read, written or listed. So no name reaches a file outside of the folder.
What a schematic becomes. The blocks with their states and the data of their block entities (the text of signs, the items of chests, the settings of machines), the minimum corner at voxel 0,0,0; the regions of a .litematic keep their places to each other. Air stays not set. A blueprint of Axiom is stored in sections of 16×16×16; its blocks keep their places to each other, and the minimum corner of its blocks becomes 0,0,0. Entities (item frames, armor stands) are left out and counted. Schematics of older Minecraft versions are upgraded like Minecraft upgrades its worlds, so renamed blocks come out with their new names; files from before Minecraft 1.13 aren't read. A schematic larger than a canvas (canvasMin, canvasMax; with the defaults 256 blocks on every axis, from 0 to 255) raises SCHEMATIC_TOO_LARGE, a file larger than maxSchematicSize too.
Replacing blocks. Every function takes the optional parameter replace, a HASH STRING from block to block, applied while the file is read. A key is an id like "create:andesite_casing" or an id with states like "oak_stairs[half=top]"; the key with the most matching states wins. The new block keeps the states of the old one that it also has, so stairs keep their direction, and the data unless the new block has data of its own. The value "" leaves the voxels not set.
Functions
- SCHEMATIC_LOAD: The schematic as a canvas.
- SCHEMATIC_MATERIALS: The items that RENDER_CANVAS takes to build the schematic, as a HASH from item id to number, counted like CANVAS_ITEMS. It works without a canvas, so it …
- SCHEMATIC_MISSING: The blocks of the schematic that this server doesn't have, as a HASH from block id to number; empty if the schematic can be built here. Blocks of mods that …
- SCHEMATIC_LIST: The schematics and canvas files in the folder schematics, sorted, as names that the other functions take: .litematic, .nbt and .bp for the functions of …
- EXPORT_SCHEMATIC: Writes a canvas as a schematic into the folder schematics, so that Litematica, Create or Axiom can place it. The extension of the name decides the format: …