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

minecraft-packager

v1.3.2

Published

A datapack/resourcepack building tool with nunjucks templating and other utilities.

Downloads

9

Readme

Minecraft Packager NPM Package

This is a multipurpose templating & linting tool for Minecraft datapacks & resource packs. It can import and merge other pack data and assets, run on command-line or in the browser, and centralize data or configuration options to template into different parts of your project.

Command-line use

The --type (datapack|resourcepack) flag can be appended to any command to declare a specific package type. By default, the packager will execute both.

minecraft-packager init will initialize the current directory as a datapack/resourcepack.

minecraft-packager build will compile the files in the /datapack and /resourcepack directories. Compiled files will be generated in the /_out directory.

minecraft-packager install will install the compiled resourcepack/datapack to the specified Minecraft location with the --mcdir flag, the $MINECRAFT_HOME environment variable, or ~/.minecraft, in that order.

Configuration

After initialization, the packager will create a default package.json file with some properties that specify the package information:

{
  "config": {
    "format": "1.17",
    "dependencies": [
      "file:./included-resource-pack.zip"
    ],
    "zipFiles": {
      "resourcepack": "custom-zip-name.resourcepack.zip",
      "datapack": "custom-zip-name.datapack.zip"
    }
  }
}

This file is also compatible with npm, so the package can be compiled & installed with just npm run dev.

Templating Syntax

.mcfunction and .json files can make use of a modified Nunjucks templating language to generate code:

  • Custom syntax uses << variable >> and <% tag %> instead of the curly braces.
  • Any .yml or .json files nested in the /_data directory are available as a global variable.
    • For example, the info property in /data/blocks/sponge.yml can be referenced as blocks.sponge.info.
  • Special filters can be used for interacting with JSON or NBT data:
    • << variable | dump >> can be used to output any variable as JSON text
    • << info.nbt_requirements | dump_nbt >> will form an NBT string from the nbt_requirements property in /_data/info.yml

Generated Files

A set of files can be "generated" from an array or object in the /_data directory by prefixing its filename with an underscore and adding some front matter to specify the data to use:

---
collection: config.teams
filename: '<< key | lower >>.json'
---
{
	"name": "<< item.name >>",
}

collection specifies the object or array to iterate through, and filename generates the file name for each item in the collection.

For each generated item, the following variables are made available for templating (in addition to the global data):

  • key: The item key (for objects, this is the property name; for arrays, the item index)
  • item: The value of the current item
  • index: The current iteration number

Linting

  • TODO: parse/validate certain command structures, e.g. execute if entity ... run ...
  • TODO: parse/validate declared scoreboard names & uses
  • TODO: correctly merge loot_tables & other specific JSON files with specific implementation
  • TODO: ability to import files from MC source (implement as node module?)
  • TODO: refactor "datapack" / "resourcepack" dirs to "data" and "assets"