tutorial:datagen_recipe
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:datagen_recipe [2022/09/10 16:43] – nexus-dino | tutorial:datagen_recipe [2023/06/05 18:08] (current) – Remove spaces mcrafterzz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | To generate recipe jsons, you have to use the '' | + | ====== Recipe Generation ====== |
| - | To get started, create a class that extends '' | + | Before reading this, make sure you've read [[datagen_setup|Getting |
| + | |||
| + | To begin, create a class that extends '' | ||
| <code java> | <code java> | ||
| private static class MyRecipeGenerator extends FabricRecipeProvider { | private static class MyRecipeGenerator extends FabricRecipeProvider { | ||
| - | private MyRecipeGenerator(FabricDataGenerator | + | private MyRecipeGenerator(FabricDataOutput |
| super(generator); | super(generator); | ||
| } | } | ||
| Line 24: | Line 26: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Adding A Shapeless Recipe ===== | ||
| + | Now that you have your recipe generator, you can call different methods depending on what you want, in this example, we will create a recipe where a '' | ||
| + | |||
| + | <code java> | ||
| + | public static Block SIMPLE_BLOCK = Registry.register(Registry.BLOCK, | ||
| + | public static BlockItem SIMPLE_ITEM = Registry.register(Registry.ITEM, | ||
| + | // ... | ||
| + | |||
| + | @Override | ||
| + | protected void generateRecipes(Consumer< | ||
| + | ShapelessRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, | ||
| + | FabricRecipeProvider.conditionsFromItem(SIMPLE_ITEM)).criterion(FabricRecipeProvider.hasItem(SIMPLE_BLOCK), | ||
| + | FabricRecipeProvider.conditionsFromItem(SIMPLE_BLOCK)).offerTo(exporter); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Adding A Shaped Recipe ===== | ||
| + | In this example, we will create a shaped recipe where a stone block is crafted from '' | ||
| + | |||
| + | <code java> | ||
| + | public static Block SIMPLE_BLOCK = Registry.register(Registry.BLOCK, | ||
| + | public static BlockItem SIMPLE_ITEM = Registry.register(Registry.ITEM, | ||
| + | // ... | ||
| + | |||
| + | @Override | ||
| + | protected void generateRecipes(Consumer< | ||
| + | ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, | ||
| + | .input(' | ||
| + | .input(' | ||
| + | .criterion(FabricRecipeProvider.hasItem(SIMPLE_ITEM), | ||
| + | FabricRecipeProvider.conditionsFromItem(SIMPLE_ITEM)) | ||
| + | .criterion(FabricRecipeProvider.hasItem(SIMPLE_BLOCK), | ||
| + | FabricRecipeProvider.conditionsFromItem(SIMPLE_BLOCK)) | ||
| + | .offerTo(exporter); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Adding A Smelting/ | ||
| + | Smelting/ | ||
| + | <code java> | ||
| + | public static final Block EXAMPLE_ORE = Registry.register(Registry.BLOCK, | ||
| + | public static final Block DEEPSLATE_EXAMPLE_ORE = Registry.register(Registry.BLOCK, | ||
| + | public static final Item EXAMPLE_ORE_ITEM = Registry.register(Registry.ITEM, | ||
| + | public static final Item DEEPSLATE_EXAMPLE_ORE_ITEM = Registry.register(Registry.ITEM, | ||
| + | public static final Item RAW_EXAMPLE = Registry.register(Registry.ITEM, | ||
| + | public static final Item EXAMPLE_INGOT = Registry.register(Registry.ITEM, | ||
| + | |||
| + | // Alternatively, | ||
| + | public static final List< | ||
| + | list.add(EXAMPLE_ORE); | ||
| + | list.add(DEEPSLATE_EXAMPLE_ORE); | ||
| + | list.add(RAW_EXAMPLE); | ||
| + | }); | ||
| + | |||
| + | @Override | ||
| + | protected void generateRecipes(Consumer< | ||
| + | RecipeProvider.offerSmelting(exporter, | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Mojang has a lot of utility methods in '' | ||
tutorial/datagen_recipe.1662828195.txt.gz · Last modified: 2022/09/10 16:43 by nexus-dino