Data Generators

From wiki.vg
Jump to: navigation, search

Data Generators are a tool added in 1.13 that can export reports about various parts of the game, and additionally are used internally by Mojang to generate various json files.

Command line

The main entry point for data generators is net.minecraft.data.Main instead of net.minecraft.client.main.Main or net.minecraft.server.MinecraftServer. This is present on both the client and the server, but since the server includes all needed libraries to run it while the client has them in separate jars, it is much easier to use the server. Since this isn't the main class, the game must be ran using a different command line than normal:

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

There are several arguments:

--help
Show the help menu (same as running with no arguments)
--input
Specify an input folder for the converters. Can be specified multiple times, as in --input folder1 --input folder2.
--output
Output folder (defaults to generated)
--client
--dev
--reports
--server
Specifies which generators to run; see the table below.
--all
Same as --client --dev --reports --server.

Generators

There are several different generators, which are controlled via the arguments above.

Name --client --dev --reports --server
SNBT -> NBT Yes No No Yes
Fluid Tags No No No Yes
Block Tags No No No Yes
Item Tags No No No Yes
Recipes No No No Yes
Advancements No No No Yes
NBT to SNBT No Yes No No
Block List No No Yes No
Item List No No Yes No
Command List No No Yes No

Blocks report

A report that contains all block states in the global palette. Notably, this contains numeric IDs as used on the protocol, so it can be used to get the proper IDs for a version. The report is saved in reports/blocks.json.

A few sample entries:

{
  "minecraft:air": {
    "states": [
      {
        "id": 0,
        "default": true
      }
    ]
  },
  "minecraft:oak_sapling": {
    "properties": {
      "stage": [
        "0",
        "1"
      ]
    },
    "states": [
      {
        "properties": {
          "stage": "0"
        },
        "id": 21,
        "default": true
      },
      {
        "properties": {
          "stage": "1"
        },
        "id": 22
      }
    ]
  }
}

The key of the object is the block ID. Within it, the properties tag contains all properties within the state, where the key within that is the property name and the value is an array of allowed property values. This tag will not be present if there are no properties. The states tag is a list of different states for the block. Within each state, the properties tag maps each property to the value on that state (which, again, will not be present if there are no properties); the id tag gives the numeric state ID (as used over the network); and the default tag indicates if the state is the default one for the block (there should be only one such state).

This report does not contain numeric block IDs, only state IDs. Block IDs only remain in use on the Block Action packet; they can be inferred by the position in the report.

Warning.png Due to MC-131740, the blocks report will delete its results if run twice in the same location.

Items report

The items report contains a list of all items, and their network IDs.

{
  "minecraft:air": {
    "protocol_id": 0
  },
  "minecraft:stone": {
    "protocol_id": 1
  }
}

Note that item IDs are no longer related to block IDs or block state IDs. They all start out in the same sequence, but some blocks do not have items and items do not include block states (by design).

Warning.png Due to MC-131740, the items report will delete its results if run twice in the same location.

Commands report

This report contains the Command Graph. The format matches information described in that article, except that name is the key for an object, and suggestions are not present in the report.

Warning.png Due to MC-131740, the commands report will delete its results if run twice in the same location.

NBT converters

There are two NBT-related data generators. One converts "SNBT" (stringified NBT - the same NBT format used in commands) to NBT; the other converts NBT into SNBT. Both look for files of the appropriate extension (.nbt or .snbt) in the input folder(s), and output them at the same relative location in the output folder.

Warning.png Due to MC-131740, the NBT to SNBT converter will delete its results if run twice in the same location.

Tag providers

The tag providers are used to create tag JSON files based off of data stored in code. As such, they aren't directly useful to people who are not writing mods. They can be used by subclassing, overriding the appropriate methods, and changing the data within.

Advancement provider

The advancement provider is used to generate advancement JSON files based off of data stored in code. It works off of nested consumers, where one layer of consumers contains the actual data (split between the different advancement categories), and that consumer takes a consumer that is actually responsible for saving the advancement. It can be used by subclassing only.

Recipes provider

The recipe JSON file creates recipes based on data in code. It can't be used directly.