Build converter
Build support has three independent layers: an in-browser converter, a 3D viewer and file-processing functions usable in Node. Conversion does not need block textures or WebGL. A 3D view additionally needs game block models and textures. Select only the layers required by the application, rather than making conversion depend on a successfully rendered preview.
Load a file and observe conversion
mosaicary-build-converter accepts a dropped file or take(file), where the argument is a Blob with an optional name. Assigning its build property offers a resource from the API; its bytes are fetched only when a format button is used, and that request counts as a download. mosaicary-convert supplies the resulting format, bytes and filename in name; browser saving has already been initiated. Local files remain in the browser. Conversion failures are displayed by the component, without a catalogue-style error event.
import 'mosaicary/catalog/define';
const converter = document.querySelector('mosaicary-build-converter');
await converter.take(file);
// Or defer fetching an API resource until its download button is used:
converter.build = build;
converter.addEventListener('mosaicary-convert', ({ detail }) => {
console.log(detail.format, detail.bytes, detail.name);
});Install game models and textures
Run npx mosaicary-blocks --out ... in Node and serve the resulting folder to mosaicary-build through its blocks attribute. --jar selects an existing client jar, --version selects the game version and --minecraft locates the game installation. Without a jar override, the installer uses a suitable installed version or downloads the client from Mojang and verifies its hash. These game files are not included in the kit and should not be offered as resource downloads.
npx mosaicary-blocks --out public/mosaicary-blocks
npx mosaicary-blocks --jar /path/client.jar --out public/mosaicary-blocks
npx mosaicary-blocks --version 1.21.1 --minecraft /path/.minecraft \
--out public/mosaicary-blocksShare block data across viewers
blockFilesAt(base) implements BlockFiles for a served directory. Share one returned object through several viewers’ blockFiles property to reuse parsed data and texture reads. A launcher may provide its own blocks() and texture(path) implementation for local storage; the latter returns a Blob or null. Set src for a file or assign the viewer’s build property for an API preview. Without block data, an Axiom blueprint may show its embedded picture; other formats explain what is missing.
import { blockFilesAt } from 'mosaicary/viewer';
const files = blockFilesAt('/mosaicary-blocks/');
for (const viewer of document.querySelectorAll('mosaicary-build')) {
viewer.blockFiles = files;
}
// A launcher can supply { blocks():Promise<Blocks>,
// texture(path):Promise<Blob|null> } instead.Convert bytes in Node
convertBuild(bytes, target) accepts axiom_blueprint, litematica or sponge_schematic. buildFileName supplies the corresponding extension; the host remains responsible for writing or returning the bytes. Litematica versions 5–7 and Sponge versions 1–3 are read; Litematica 7 and Sponge 3 are written. A request for the existing format preserves the original bytes. Conversion preserves available block states and entities but does not make every modded state compatible with a different game installation.
import { readFile, writeFile } from 'node:fs/promises';
import { convertBuild, buildFileName } from 'mosaicary/builds';
const bytes = new Uint8Array(await readFile('house.bp'));
const converted = await convertBuild(bytes, 'litematica');
await writeFile(buildFileName('house', 'litematica'), converted);Place exported files in the game
Use the directory associated with the receiving mod, as listed below; these are game or mod directories, not folders created automatically by the converter. Keep the filename extension produced for the chosen format. Installing a file does not install the corresponding mod. An application may offer saving to a user-selected location instead of assuming the game path, especially when several launcher instances have separate game directories.
Axiom | .minecraft/config/axiom/blueprints |
|---|---|
Litematica | .minecraft/schematics |
WorldEdit | config/worldedit/schematics |