Skip to content

Getting started

  • Node.js 22.22 or newer.
  • Java, for running the Minecraft server. MSPacker prefers the Java runtime the Minecraft launcher installed for your version, then JAVA_HOME, then java on your PATH. See java.
Terminal window
npm create mspacker@latest
# or: pnpm create mspacker / yarn create mspacker / bun create mspacker

The setup asks for:

  • Project directory: where to create the project.
  • Namespace: your data pack’s namespace, such as mypack. See namespaces for the mypack:generated/ form.
  • Minecraft version: the list has the latest release and snapshot, the latest patch of every minor version since 1.13 (the first version with data packs), every 1.21 game drop, and the April Fools versions at the bottom. Pick Other version… to search every version that supports data packs.
  • Description: shown in the in-game pack list.

It then installs dependencies and offers to generate the command library. Generating downloads the official server jar for your version (about 50 MB, downloaded once per version) and reads its commands from it.

To skip the questions, pass the answers as flags:

Terminal window
npm create mspacker@latest my-pack -- --version 26.3 --namespace mypack --yes
Flag Meaning
--version <id> Minecraft version
--namespace <ns> Namespace
--description <text> Pack description
--yes Accept defaults for everything not given
--no-install Don’t install dependencies
--no-gen Don’t generate the command library

Run it in the project’s folder:

Terminal window
npm create mspacker@latest .

Existing files are kept: it adds mspacker.config.ts, the #mc import, scripts and dependencies in package.json, tsconfig.json, .gitignore entries and src/main.ts.

Terminal window
npm run gen # generate the typed command library into .mspacker/gen
npm run build # build the data pack into dist/<name>
npm run dev # rebuild into a dev server on every save and /reload it

Your code imports $ from #mc, a package import that points at the generated library. Every command hangs off it: $.say("hi"), $.execute.as("@a").run.say("hi"). See commands. Run gen again whenever you change version.

src/main.ts from the template:

import { $ } from "#mc";
/** @load */
export function Init() {
$.say("Datapack loaded!");
}
/** @mcfunction */
export function Greet() {
$.execute.as("@a").at("@s").run.tellraw("@s", { text: "Hello!", color: "gold" });
}

npm run build writes:

dist/my-pack/
pack.mcmeta
data/mypack/function/main/init.mcfunction # say Datapack loaded!
data/mypack/function/main/greet.mcfunction # execute as @a at @s run tellraw @s {...}
data/minecraft/tags/function/load.json # ["mypack:main/init"]

In game, run /function mypack:main/greet.