npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prismarine-schematic

v1.2.3

Published

Read, write and manipulate minecraft schematics

Downloads

1,694

Readme

prismarine-schematic

NPM version Build Status Discord Gitter Irc Try it on gitpod

Read, write and manipulate minecraft schematics.

Supported formats:

Usage

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()

API

Schematic

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

Schematic.start()

Return the start coordinate of this schematic.

Schematic.end()

Return the end coordinate of this schematic.

Schematic.forEach(cb)

calls the callback on every block in the schematic. the callback is called with args (block, pos).

Schematic.map(cb)

returns an array of the results from calling the callback on every block in the schematic. the callback is called with args (block, pos).

Schematic.makeWithCommands(offset, platform = 'pc')

  • platform is a optional parameter. It can be pc (default) or pe 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

Schematic.getBlockStateId(pos)

Get the stateId of the block at pos. pos must be between start() and end().

Schematic.getBlock(pos)

Get the block at pos. pos must be between start() and end().

Schematic.setBlock(pos, block)

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.

Schematic.copy(world, start, end, offset, version)

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.

Schematic.paste(world, at)

Async. Paste the schematic in world (prismarine-world) at the at (vec3) location.

Schematic.read(buffer, version=null)

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.

Schematic.write()

Async. Return a buffer encoding this schematic

Schematic.toJSON(space?)

Returns string representation off the schematic. space represents the space option for JSON.stringify().

Schematic.fromJSON()

Returns a new Schematic instance by parsing a stringified schematic. Returns null on error.