Codec2Schema is a tool that generates JSON schemas for codecs.
Simply launch the game with the mod installed, and JSON schemas for all sorts of things will be exported to the codec2schema folder in the run directory.
Please note that this never works might fail with other mods installed.
INFO
How to build codecs is not covered here. For info on that (and more), see the Fabric Documentation
What Is a JSON Schema?
A JSON Schema is a file that describes how a JSON file should be structured. It also provides default values, descriptions, and more. Minecraft uses JSON files for data and resource packs, and this mod generates JSON schemas that can be used to provide autocomplete when creating or editing JSON files.
Installation
Add the following to the repositories block in your build.gradle if you haven't already:
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}2
3
4
5
6
7
Add the following to the dependencies block in your build.gradle:
implementation "maven.modrinth:trutils:${project.trutils_version}"The Entrypoint
For your mod to interface with Codec2Schema, you'll need to create an entrypoint.
public class ExampleCodec2SchemaPlugin implements Codec2SchemaPlugin {
// Override methods from Codec2SchemaPlugin to do cool things!
}2
3
In your fabric.mod.json:
{
[...]
"entrypoints": {
"codec2schema:main": ["com.example.ExampleSchemaGenerator"]
}
[...]
}2
3
4
5
6
7
TIP
You can use the codec2schema:client entrypoint if you only want stuff to happen on the client.