@taku128/mcstructure
v0.2.3
Published
Convert Bedrock .mcstructure files to Java Structure NBT. Browser- and Node-compatible (no LevelDB required).
Readme
@taku128/mcstructure
Convert Bedrock .mcstructure files to Java Edition Structure NBT.
Works in the browser (File API) and Node.js.
Install
npm install @taku128/mcstructureBrowser usage
import { convertMcstructureBuffer } from '@taku128/mcstructure';
// From <input type="file">
const buf = new Uint8Array(await file.arrayBuffer());
const result = await convertMcstructureBuffer(buf);
// result.nbt — Uint8Array (gzipped Java Structure NBT)
// result.size — [x, y, z]
// result.blockCount — non-air blocks
// result.paletteCount — unique block statesNode.js usage (file path)
import { convertMcstructure } from '@taku128/mcstructure/node';
const result = await convertMcstructure('./build.mcstructure');
import { writeFileSync } from 'node:fs';
writeFileSync('build.nbt', result.nbt);API
convertMcstructureBuffer(buffer: Uint8Array | ArrayBuffer): Promise<ConvertResult>
Browser-safe. Parses a .mcstructure buffer and returns Java NBT.
convertMcstructure(inputPath: string): Promise<ConvertResult> — /node subpath
Node-only. Reads the file at inputPath and delegates to convertMcstructureBuffer.
ConvertResult
interface ConvertResult {
nbt: Uint8Array; // gzipped Java Structure NBT
size: [number, number, number];
blockCount: number; // non-air Java blocks
paletteCount: number; // unique Java block states
}License
MIT
