Converts Litematica .litematic schematic files between Minecraft versions, rewriting the
block and item palette so anything the target version doesn't have gets substituted instead of
silently disappearing.
npm install @froyln/schem-convert-libconst fs = require('fs');
const { convertFile } = require('@froyln/schem-convert-lib');
const input = fs.readFileSync('build.litematic');
const { buffer, report } = await convertFile(input, '1.12.2');
fs.writeFileSync('build-1.12.2.litematic', buffer);
console.log(report.blockLines()); // e.g. ["minecraft:vault -> minecraft:command_block"]See docs/usage.md for the full guide: detecting a source version, reading the substitution report, error handling, and working with an already-parsed NBT tree.
inspectFile(buffer)— gunzips and parses a.litematicbuffer, returns{ nbtVersion, dataVersion, label }describing the source version without converting it.convertFile(buffer, toMcVersion)— converts a gzipped.litematicbuffer totoMcVersion, returns{ buffer, report }.bufferis the converted, re-gzipped file.reportexposesblockLines(),itemLines(),noteLines(), andtoLines().convertSchematic(root, fromDataVersion, toMcVersion)— the low-level entry point for callers that already hold a parsed NBT root (e.g. viaprismarine-nbt). Mutatesrootin place and returns the same report.SUPPORTED— map of target Minecraft version string to its Litematica NBT version.PRE_FLATTENING_MC_VERSION—'1.12.2', the one selectable target not inSUPPORTED(see Limitations below).
Both inspectFile and convertFile are async (prismarine-nbt's parser is promise-based).
1.12.2, and 1.13.2 through 26.1 (every version in SUPPORTED, plus 1.12.2 as a
downgrade-only target). Mojang dropped the "1." prefix in 2026: 26.1 is the year/drop successor
to the 1.21.x line, not a typo. 26.2 exists as a released Minecraft version but isn't supported
here yet — minecraft-data, the upstream
project this library's block/item data is generated from, hasn't published its data yet.
- 1.12.2 is downgrade-only. 1.12.2 predates the Flattening (block ids became per-name
states in 1.13); this library translates modern states down to 1.12.2's
id:metamodel, but does not un-flatten a 1.12.2 source back up. Uploading an actual 1.12.2 schematic and converting it to a newer version is unsupported for blocks, signs, and items alike. - Palette length never changes. Litematica packs
BlockStatesindices atceil(log2(paletteSize))bits; a substitution replaces a palette entry in place rather than adding or removing one. - Known open bug: upgrading a
cauldron[level=2](partially filled) past its rename boundary loses thelevelproperty and silently becomes an empty cauldron, sincecauldronexists in every target and the substitution resolver is never invoked for it. Vanilla's data-fixer produceswater_cauldronhere; this library does not yet.
npm test # node --test test/*.test.js
npm run build-data # regenerate data/blocks-<version>.json from minecraft-dataSee docs/architecture.md for the full conversion-logic writeup.
MIT © froyln.
data/vendor/block_state_map.json is vendored unmodified from the
Litematica mod and is licensed separately under
LGPL-3.0 — see data/vendor/NOTICE.md and data/vendor/LICENSE.txt. It is not covered by this
package's MIT license; it is included and used unmodified per LGPL's "used as a library" terms.