Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cad3e49
Implement Data Gen API prototype for 1.13-1.14
thecatcore Sep 16, 2026
afb1195
Add a basic ModLanguage Provider
thecatcore Sep 16, 2026
ce443a6
Refactor and now use a wrapper system for 1.13+
thecatcore Sep 18, 2026
c0db61c
Add basic providers for modded Advancements and LootTables
thecatcore Sep 21, 2026
505cc7a
Add ModModelProvider for generating blockstates and block and item mo…
thecatcore Sep 22, 2026
4ae39a1
Improvements to the way providers are registered in the PackGenerator
thecatcore Oct 5, 2026
35b6b53
Add documentation to the data-gen module.
thecatcore Oct 5, 2026
96f0286
Add more model templates
thecatcore Oct 5, 2026
b0fbf7b
Fix build errors
thecatcore Oct 5, 2026
1dc5a7c
Run Bootstrap before running data generators
thecatcore Oct 5, 2026
cb3b450
Address review comments
thecatcore Oct 8, 2026
5971555
Fix injected interface name
thecatcore Oct 8, 2026
5079e0e
[datagen] Allow adding translations from existing files
thecatcore Oct 19, 2026
a52cb8f
[datagen] Pluralise mod data providers
thecatcore Oct 21, 2026
817d27e
[datagen] Add data providers for tags
thecatcore Oct 21, 2026
baca74b
[datagen] datagen for 1.13.x
thecatcore Oct 21, 2026
98b754b
[datagen] Fix block and item prefixing in ModModelsProvider
thecatcore Nov 1, 2026
d12de3a
[datagen] Add support for model-based simple block templates
thecatcore Nov 1, 2026
56397b2
[datagen] Fix stairs model template
thecatcore Nov 4, 2026
59c6329
[datagen] Fix generated language path
thecatcore Nov 4, 2026
0c3368e
[datagen] Add loot table sub-providers
thecatcore Nov 4, 2026
27bfdb2
[datagen] Fix entity loot table identifier conversion
thecatcore Nov 5, 2026
e27ed2c
[datagen] split module between 1.13.x and 1.14.x again
thecatcore Nov 5, 2026
125ed12
[datagen] Add mod id helper to recipe providers and version cache hea…
thecatcore Nov 5, 2026
b979878
[datagen] Preserve insertion order in generated data for translations…
thecatcore Nov 5, 2026
ae3d9a6
[datagen] Preserve insertion order in block state predicates
thecatcore Nov 7, 2026
c1d1bac
[datagen] Remove Bootstrap (re)-init from data generator setup
thecatcore Nov 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions libraries/datagen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Data Generator API

The Data Generator API is a library that provides a simple and intuitive way to generate data files for Minecraft mods.
It allows mod developers to easily create block models, item models, and other data files without having to manually write JSON files.

## Registering Data Generators
### Entrypoint

The Data Generator API provides an entrypoint that allows mod developers to register their data generators.
This entrypoint is used to register the data generators that will be used to generate the data files for the mod.

An example is shown below.

`fabric.mod.json`
```json
{
...
"entrypoints": {
...
"datagen": [
"com.example.ExampleDataGenerator"
],
...
},
...
}
```

```java
package com.example;

import net.ornithemc.osl.datagen.api.DataGeneratorInitializer;

public class ExampleDataGenerator implements DataGeneratorInitializer {
@Override
public void onDatagenInit(ModDataGenerator dataGenerator) {
PackGenerator pack = dataGenerator.createPack();
pack.addProvider(ExampleModelProvider::new);
}
}
```

### Mod Data Providers

Mod data providers are used to provide data to the pack generator.
There are a few builtin providers, such as the model provider, and language provider.

An example for the model provider is shown below.

```java
package com.example;

public class ExampleModelProvider extends ModModelProvider {
public ExampleModelProvider(PackGenerator generator, ModContainer mod) {
super(generator, mod);
}

public void generateModels(ModelGenerator generator) {
BlockModelTemplates templates = generator.blockTemplates();
templates.simpleBlock(Blocks.OAK_PLANKS, block("oak_planks"));
}
}
```

Vanilla DataProviders can also be extended to provide data such as tags.
In the extended constructor, replace DataGenerator with PackGenerator and upcast it back to DataGenerator.
6 changes: 6 additions & 0 deletions libraries/datagen/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
setUpLibrary(project)

dependencies {
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.guava:guava:17.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setUpModule(project)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
min_mc_version = 1.13-pre6
max_mc_version = 18w31a

minecraft_version = 1.13
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package net.ornithemc.osl.datagen.api.model;

import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import net.ornithemc.osl.core.api.util.NamespacedIdentifier;

import java.util.HashMap;
import java.util.Map;

/**
* Represents a block or item model.
*/
public class ModelBuilder {
private NamespacedIdentifier parent;
private Map<String, NamespacedIdentifier> textures = Maps.newLinkedHashMap();

/**
* Creates a new model builder.
*
* @return the model builder
*/
public static ModelBuilder create() {
return new ModelBuilder();
}

/**
* Creates a new model builder with the given parent.
*
* @param parent the parent model
* @return the model builder
*/
public static ModelBuilder create(NamespacedIdentifier parent) {
return new ModelBuilder().parent(parent);
}

/**
* Sets the parent model.
*
* @param parent the parent model
* @return the model builder
*/
public ModelBuilder parent(NamespacedIdentifier parent) {
this.parent = parent;
return this;
}

/**
* Sets the texture path for the given name.
*
* @param name the name of the texture
* @param texture the texture path
* @return the model builder
*/
public ModelBuilder texture(String name, NamespacedIdentifier texture) {
this.textures.put(name, texture);
return this;
}

public JsonObject build() {
JsonObject model = new JsonObject();

if (parent != null) {
model.addProperty("parent", parent.toString());
}

if (!textures.isEmpty()) {
JsonObject texturesJson = new JsonObject();
for (Map.Entry<String, NamespacedIdentifier> entry : textures.entrySet()) {
texturesJson.addProperty(entry.getKey(), entry.getValue().toString());
}
model.add("textures", texturesJson);
}

return model;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.ornithemc.osl.datagen.api.model;

import net.minecraft.block.Block;
import net.minecraft.item.ItemLike;
import net.ornithemc.osl.core.api.util.NamespacedIdentifier;
import net.ornithemc.osl.datagen.api.model.block.BlockModelDefinitionBuilder;
import net.ornithemc.osl.datagen.api.model.block.BlockModelTemplates;

/**
* Provides methods for generating model resources.
*/
public interface ModelGenerator {
/**
* Generates a blockstate file for the given block.
*
* @param block the block to generate the blockstate for
* @param builder the builder to use for generating the blockstate
*/
void blockstate(Block block, BlockModelDefinitionBuilder builder);

/**
* Generates an item model file for the given item or block item.
*
* @param item the item to generate the item model for
* @param builder the builder to use for generating the item model
*/
void itemModel(ItemLike item, ModelBuilder builder);

/**
* Generates a block model file for the given identifier.
*
* @param identifier the identifier to generate the block model for
* @param builder the builder to use for generating the block model
* @return the generated block model identifier
*/
NamespacedIdentifier blockModel(NamespacedIdentifier identifier, ModelBuilder builder);

/**
* Generates a block model file for the given block.
*
* @param block the block to generate the block model for
* @param builder the builder to use for generating the block model
* @return the generated block model identifier
*/
NamespacedIdentifier blockModel(Block block, ModelBuilder builder);

/**
* Generates a block model file for the given block with the given suffix.
*
* @param block the block to generate the block model for
* @param suffix the suffix to append to the block model identifier
* @param builder the builder to use for generating the block model
* @return the generated block model identifier
*/
NamespacedIdentifier blockModel(Block block, String suffix, ModelBuilder builder);

/**
* Returns the block model templates.
*
* @return the block model templates
*/
BlockModelTemplates blockTemplates();
}
Loading
Loading