Tutorials/Running the data generator

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Java Edition. 
Gear (item).gif
This article is a work in progress. 
Please help in the creation of this article by expanding or improving it. The talk page may contain suggestions.

This tutorial shows how to run the data generator that is included in Java Edition client and server distributions since 1.13.


The data generator can:

  • Convert G-Zip compressed NBT format files with .nbt extensions (as used in Structure files) from and to String NBT format files with .snbt extensions.
  • Generate all contents of the vanilla data pack
  • Create JSON reports of all block states, all registries, and the full vanilla command tree

Getting Started[edit]

To launch the data generator, it is recommended that you download the official server distribution of the Minecraft version you desire.

Then, open a bash or command prompt in the directory where you have the server jar, and run (make sure you have Java installed)

java -cp server.jar net.minecraft.data.Main

If you have set up correctly, the command line will show a list of options and descriptions.

Generating data pack contents[edit]

In the same command line interface, run

java -cp server.jar net.minecraft.data.Main --server

The contents of the vanilla data pack (except pack.mcmeta) will be generated to generated directory in the run directory of the command line interface.

Generating stringified server DAT files[edit]

Many of the server data files located in the world directory of the game server bear the .dat extension. Many of these files are actually saved in Named Binary Tag (NBT) format used widely throughout Minecraft. Follow these steps to use the data generator tools distributed with the Minecraft server JAR to convert these files to a human-readable "stringified" format:

  1. Open a terminal or command prompt of your choice on your game server
  2. Create a new directory named input in the same directory as your game server JAR
    mkdir input
  3. Copy any qualifying .dat file which is actually written in NBT format into the input directory you created and re-save it with the .nbt extension
    # (linux-only)
    cp world/level.dat input/level.nbt
    # (windows-only)
    copy world\level.dat input\level.nbt
  4. Use the --dev flag to activate the development generator which is capable of converting a directory of NBT files into a directory of "stringified" NBT (SNBT) files [1]
    java -cp server.jar net.minecraft.data.Main --dev --input "input"
    If it worked, you'll get some output that looks like this
    [17:17:17] [main/INFO]: Starting provider: NBT to SNBT
    [17:17:17] [main/INFO]: NBT to SNBT finished after 3 ms
    [17:17:17] [main/INFO]: All providers took: 34 ms
    You should also have a new directory named generated in the current directory where you ran the command. Inside will be the stringified version of each file you supplied as input.
  5. Use command-line tools of your choice (e.g. cat on linux systems) to view them immediately, or use a GUI text editor of your choice to open them

Stringify all DAT files:[edit]

If you'd like to stringify every DAT file currently on your server (for experimentation, curiosity, or whatever):

  1. Start from the same directory where your input directory is located, then run this command to recursively copy all the DAT files into it[2]. Replace path/to/world/data with the relative path to the directory holding the world data in your game server. By default, Minecraft creates this directory in the same directory as the server JAR, and names it world. Unless you've changed the world name in server.json or moved this directory somewhere else, you can probably just replace that entire path with world
    # (linux-only)
    find path/to/world/data -name \*.dat -exec cp {} input \;
  2. Rename all of these files with the .nbt extension[3]:
    # (linux-only)
    for file in input/*.dat; do mv "$file" "${file/.dat/.nbt}"; done
  3. Re-run the data generator with the --dev flag as described above in step 4


See also[edit]