Codec2Schema

A tool to convert codecs to JSON schemas.

2 083 downloads 4 followers

Codec2Schema

Through the power of mixins, sheer will, and unchecked type casts, this mod transforms codecs into (mostly) usable JSON schemas.

You can find the generated schemas for vanilla Minecraft here.

What is a Codec?

Codecs are Mojang's way of easily serializing data to and from JSON. They define the structure of an object, meaning JSON schemas can be generated from them.

What is a JSON Schema?

A JSON schema is a file that describes how JSON files should be structured, and can be used by IDEs to provide autocomplete when creating or editing JSON files.

About This Mod

When installed, this mod exports JSON schemas for data and resource pack files to <YOUR GAME DIRECTORY>/codec2schema. You can use the API to export your own codecs as well!

The generated JSON schemas will have autocomplete for registries (items, blocks, etc), including modded content.

This mod is not perfect: there are many edge cases that aren't or can't be accounted for.

Example

The following is the generated JSON schema for regional compliancies warnings:

{
  "$schema": "https://json-schema.org/draft-07/schema",
  "$ref": "#/definitions/def",
  "definitions": {
    "def": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/def_1"
        }
      }
    },
    "def_1": {
      "type": "object",
      "properties": {
        "delay": {
          "type": "integer",
          "minimum": -9223372036854775808,
          "maximum": 9223372036854775807,
          "default": 0
        },
        "period": {
          "type": "integer",
          "minimum": -9223372036854775808,
          "maximum": 9223372036854775807
        },
        "title": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "period",
        "title",
        "message"
      ]
    }
  }
}

It's not perfect, but it's good enough.

No gallery available for this project.

Version Minecraft Loader Download

0.3.7+26.4-snapshot-3

26.4-snapshot-3, 26.4-snapshot-4, 26.4-snapshot-5, 26.4-snapshot-6, 26.4-snapshot-7, 26.4-snapshot-8
fabric
Download

0.3.7+26.4-snapshot-1

26.4-snapshot-1, 26.4-snapshot-2
fabric
Download

0.3.7+26.3-pre-1

26.3, 26.3-pre-1, 26.3-pre-2, 26.3-pre-3, 26.3-rc-1, 26.3-rc-2, 26.3-rc-3
fabric
Download

0.3.7+26.3-snapshot-10

26.3-snapshot-10
fabric
Download

0.3.7+1.21.11

1.21.11
fabric
Download

0.3.7+26.1.2

26.1, 26.1.1, 26.1.2, 26w14a
fabric
Download

0.3.7+26.3-snapshot-9

26.3-snapshot-9
fabric
Download

0.3.7+26.3-snapshot-8

26.3-snapshot-8
fabric
Download

0.3.7+26.2

26.2
fabric
Download

0.3.6+26.3-snapshot-6

26.3-snapshot-6, 26.3-snapshot-7
fabric
Download

0.3.6+26.3-snapshot-5

26.3-snapshot-5
fabric
Download

0.3.6+26.3-snapshot-4

26.3-snapshot-4
fabric
Download

0.3.6+26.3-snapshot-3

26.3-snapshot-3
fabric
Download

0.3.6+26.3-snapshot-2

26.3-snapshot-2
fabric
Download

0.3.6+26.3-snapshot-1

26.3-snapshot-1
fabric
Download

0.3.6+26.2

26.2
fabric
Download

0.3.6+1.21.11

1.21.11
fabric
Download

0.3.6+26.2-pre-6

26.2-pre-5, 26.2-pre-6, 26.2-rc-1, 26.2-rc-2
fabric
Download

0.3.6+26.1.2

26.1, 26.1.1, 26.1.2, 26w14a
fabric
Download

0.3.5+26.2-snapshot-8

26.2-pre-1, 26.2-pre-2, 26.2-pre-3, 26.2-pre-4, 26.2-pre-5, 26.2-snapshot-7, 26.2-snapshot-8
fabric
Download

0.3.5+26.1.2

26.1, 26.1.1, 26.1.2, 26w14a
fabric
Download

0.3.4+26.2-snapshot-3

26.2-snapshot-1, 26.2-snapshot-2, 26.2-snapshot-3, 26.2-snapshot-4, 26.2-snapshot-5, 26.2-snapshot-6, 26.2-snapshot-7, 26.2-snapshot-8
fabric
Download

0.3.4+26.1.2

26.1, 26.1.1, 26.1.2, 26w14a
fabric
Download

0.3.3+26.2-snapshot-1

26.2-snapshot-1, 26.2-snapshot-2
fabric
Download

0.3.3+26.1.1

26.1, 26.1.1, 26.1.1-rc-1, 26.1.2, 26.1.2-rc-1, 26w14a
fabric
Download

0.3.2+26.1

26.1, 26.1.1, 26.1.1-rc-1, 26w14a
fabric
Download

0.2.4+1.21.11

1.21.11
fabric
Download

0.3.1+26.1

26.1, 26.1.1-rc-1
fabric
Download

0.3.0+26.1

26.1
fabric
Download

0.3.0-beta.2+26.1

26.1
fabric
Download

0.3.0-beta.1+26.1-pre-1

26.1-pre-1, 26.1-pre-2, 26.1-pre-3, 26.1-rc-1, 26.1-rc-2, 26.1-rc-3
fabric
Download

0.2.3+1.21.11

1.21.11
fabric
Download

0.2.2+26.1-snapshot-11

26.1-snapshot-11
fabric
Download

0.2.2+1.21.11

1.21.11
fabric
Download

0.2.1+26.1-snapshot-11

26.1-snapshot-11
fabric
Download

0.2.1+26.1-snapshot-10

26.1-snapshot-10
fabric
Download

0.2.1+26.1-snapshot-8

26.1-snapshot-8, 26.1-snapshot-9
fabric
Download

0.2.1+26.1-snapshot-7

26.1-snapshot-7
fabric
Download

0.2.1+26.1-snapshot-6

26.1-snapshot-6
fabric
Download

0.2.1+1.21.11

1.21.11
fabric
Download

0.2.0+26.1-snapshot-5

26.1-snapshot-5
fabric
Download

0.2.0+1.21.11

1.21.11
fabric
Download

0.1.4+26.1-snapshot-4

26.1-snapshot-4
fabric
Download

0.1.4+1.21.11

1.21.11
fabric
Download

0.1.3+26.1-snapshot-3

26.1-snapshot-3
fabric
Download

0.1.3+26.1-snapshot-2

26.1-snapshot-2
fabric
Download

0.1.3+1.21.11

1.21.11
fabric
Download

0.1.2+26.1-snapshot-1

26.1-snapshot-1
fabric
Download

0.1.2+1.21.11

1.21.11
fabric
Download

0.1.1+1.21.11

1.21.11
fabric
Download

0.1.0+1.21.11

1.21.11
fabric
Download