Skip to content

Getting Started with MC-Build

Getting started with MC-Build is easy! This guide will walk you through the process of installing MC-Build and creating your first project.

Installing MC-Build

In order to install MC-Build, You'll first need Node.js.

If you don't already have Node.js, visit their site (nodejs.org) and download and run the installer.

Once you've installed Node.js, open a command prompt and run the following command:

npm i -g mc-build@latest

That's it! MC-Build is now installed.

You can run mcb in the command prompt to verify that MC-Build is installed correctly:

$ mcb
[MCB x.y.z] MCB - A Minecraft Data Pack build tool.
[MCB x.y.z]
[MCB x.y.z] Usage:
...

Run mcb --version to see which version you have.

Creating a New Project.

MC-Build comes with a command to help you quickly setup a new project. Simply navigate to your chosen world/datapacks folder, then run the following command:

mcb create my_epic_datapack

This will create a new folder called my_epic_datapack in your world/datapacks folder, and set up a basic project structure for you.

The Project Structure

  • my_epic_datapack - This is the root folder of your project.
    • pack.mcmeta - This file is identical to a vanilla pack.mcmeta file. MC-Build reads its pack_format to choose the correct folder names for your Minecraft version.
    • src/ - This folder is where you'll write your MC-Build code.
    • data/ - MC-Build will compile your code into this folder, which is the same structure as a vanilla data pack.
    • .mcb/ - MC-Build keeps a list of the files it generated here, so it can delete files that you remove from your code.
    • mcb.config.js - The configuration file for your project.

Building Your Project

Navigate to your project folder and run the following command:

mcb watch

This will start the MC-Build compiler in watch mode, which will automatically compile your code whenever you make changes.

You can also run mcb build to compile your code once, without watch mode.

That's it! Your project is now ready for development.

Configuration

mcb.config.js exports an object with these options. All of them are optional. You can also use mcb.config.json.

Option Default Description
generatedDirName "zzz" The folder that MC-Build puts generated functions in.
internalScoreboardName "mcb.internal" The scoreboard that MC-Build uses for internal values, for example in execute if / else blocks.
eqVarScoreboardName "mcb.eq.var" The scoreboard for temporary values in eq expressions.
eqConstScoreboardName "mcb.eq.const" The scoreboard for constant values in eq expressions.
header "# Generated with MC-Build\n" The text at the top of each generated .mcfunction file.
dontEmitComments false When true, kept comments are not written to the output.
formatVersion from pack.mcmeta The data pack format to compile for. Set this if your pack.mcmeta has no numeric pack.pack_format.
setup null A function that receives the compiler config before the first build. Use config.events.onPreBuild.subscribe(callback) and config.events.onPostBuild.subscribe(callback) to run code before and after each build. Callbacks can be async.

You can also add your own keys. Script blocks can read them through the config object.

What's Next?

Check out the Language Features documentation for more information on how to write MC-Build code.