Data And Recipes
Generate data, tags and recipe JSON with stable mc specs.
Some APIs may still change or behave unevenly because they do not have enough real-world use cases and test coverage yet.
Data And Recipes
Data APIs let generated mods describe common Minecraft data once. The adapter writes or stores the version-specific shape later.
Tags With TagSpec
Use TagSpec when generated content needs item or block tags.
TagSpec machineBlocks = TagSpec.blocks(
"my_mod:machines",
List.of("my_mod:oven", "my_mod:crusher"));
MinecraftApi.dataGen(context).writeTag(machineBlocks);
Prefer stable tag specs for generated tags. Use native data generators when the tag format or target registry is not covered.
Ingredients
IngredientSpec can point at item ids or a tag id.
IngredientSpec copper = IngredientSpec.item("minecraft:copper_ingot");
IngredientSpec planks = IngredientSpec.tag("minecraft:planks");
Use this in RecipeSpec and WorkstationRecipeSpec.
Basic Recipes
Use RecipeSpec for common shaped, shapeless and cooking-like generated recipes.
RecipeSpec recipe = RecipeSpec.shaped("my_mod:machine", McItemStack.of("my_mod:machine"))
.pattern("AAA")
.pattern("ABA")
.pattern("AAA")
.key('A', IngredientSpec.item("minecraft:iron_ingot"))
.key('B', IngredientSpec.tag("minecraft:planks"))
.build();
MinecraftApi.dataGen(context).writeRecipe(recipe);
If the recipe has custom runtime matching or serialization, register a native RecipeSerializer through RegistryApi and generate the JSON your serializer expects.
Workstation Recipes
Use WorkstationRecipeSpec for machine-like recipes that have inputs, output, time and optional experience.
WorkstationRecipeSpec smelting = WorkstationRecipeSpec.builder(
"my_mod:oven/copper_plate",
"my_mod:oven")
.ingredient(IngredientSpec.item("minecraft:copper_ingot"))
.result(McItemStack.of("my_mod:copper_plate"))
.cookingTime(160)
.experience(0.2F)
.build();
MinecraftApi.dataGen(context).writeJson(
"data/my_mod/recipe/oven/copper_plate.json",
Map.of(
"type", smelting.typeId(),
"ingredient", DataGen.ingredientJson(smelting.ingredients().get(0)),
"result", smelting.results().get(0).itemId(),
"cookingtime", smelting.cookingTime(),
"experience", smelting.experience()));
Your machine still owns inventory, ticking, lookup and output logic. Nows only helps keep generated recipe data consistent.
Data Packs And Resource Packs
Use DataPacks to register existing native pack sources against a stable target.
MinecraftApi.dataPacks(context).registerSource(
PackTarget.SERVER_DATA,
myServerDataPackSource);
Use PackTarget.CLIENT_RESOURCES for client resources such as models, textures and language files.
Recipe display metadata is separate. Use Recipe Viewer Metadata only if a mod wants to expose optional category/layout information for another integration to consume later.