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.
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.
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
.
.mcfunction
and .json
files can make use of a modified Nunjucks templating language to generate code:
<< variable >>
and <% tag %>
instead of the curly braces..yml
or .json
files nested in the /_data
directory are available as a global variable.
info
property in /data/blocks/sponge.yml
can be referenced as blocks.sponge.info
.<< 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
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 itemindex
: The current iteration numberexecute if entity ... run ...