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/12/21 07:02] – jmanc3 | tutorial:datagen_recipe [2023/06/05 18:08] (current) – Remove spaces mcrafterzz | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| <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 37: | Line 37: | ||
| @Override | @Override | ||
| protected void generateRecipes(Consumer< | protected void generateRecipes(Consumer< | ||
| - | ShapelessRecipeJsonBuilder.create(SIMPLE_ITEM).input(SIMPLE_BLOCK).offerTo(exporter); | + | 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)) | ||
| + | | ||
| } | } | ||
| </ | </ | ||
tutorial/datagen_recipe.1671606149.txt.gz · Last modified: 2022/12/21 07:02 by jmanc3