Read, write and manipulate minecraft schematics.
Supported formats:
const fs = require('fs').promises
const { Schematic } = require('prismarine-schematic')
async function main () {
// Read a schematic (sponge or mcedit format)
const schematic = await Schematic.read(await fs.readFile('test/schematics/smallhouse1.schem'))
// Write a schematic (sponge format)
await fs.writeFile('test.schem', await schematic.write())
}
main()
A schematic instance.
- version : the mc version of this schematic
- size : vec3, the size in blocks
- offset : vec3, offset from 0
- palette : list of stateIds for the palette of this schematic
- blocks: indices in the palette for each blocks in y, z, x order
Return the start coordinate of this schematic.
Return the end coordinate of this schematic.
calls the callback on every block in the schematic. the callback is called with args (block, pos)
.
returns an array of the results from calling the callback on every block in the schematic. the callback is called with args (block, pos)
.
platform
is a optional parameter. It can bepc
(default) orpe
to account for a different command style between Java and Pocket Edition.
returns an array of commands to run to make the schematic in a vanilla server. the offset is a vec3 instance that is applied by .offset on each block in the schematic.
-
In 1.13+, there are block states as an array in the commands
-
In 1.11+, there are block states as metadata as a number in the commands
-
In <1.11, there is no block state, just the block in the commands
Get the stateId of the block at pos
. pos
must be between start()
and end()
.
Get the block at pos
. pos
must be between start()
and end()
.
Set a block at pos
to a block of Block instance (see prismarine-block). If block is not given or nullish setBlock removes the block at pos
.
Static, async. Make a schematic instance from world
(prismarine-world) between start
and end
(vec3), offset
will be the offset of the schematic, version
must match world
's version.
Async. Paste the schematic in world
(prismarine-world) at the at
(vec3) location.
Static, async. Return a Schematic instance, read from the buffer. If version is not set, the loader try to autodetect the version from the file.
Async. Return a buffer encoding this schematic
Returns string
representation off the schematic. space
represents the space option for JSON.stringify()
.
Returns a new Schematic
instance by parsing a stringified schematic. Returns null
on error.