User Tools

Site Tools


tutorial:datagen_recipe

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:datagen_recipe [2023/06/05 17:47] – Added recipe category mcrafterzztutorial:datagen_recipe [2023/06/05 18:08] (current) – Remove spaces mcrafterzz
Line 37: Line 37:
 @Override @Override
 protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) { protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) {
-          ShapelessRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, SIMPLE_ITEM).input(SIMPLE_BLOCK).offerTo(exporter);+          ShapelessRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, SIMPLE_ITEM).input(SIMPLE_BLOCK).criterion(FabricRecipeProvider.hasItem(SIMPLE_ITEM),  
 +          FabricRecipeProvider.conditionsFromItem(SIMPLE_ITEM)).criterion(FabricRecipeProvider.hasItem(SIMPLE_BLOCK),  
 +          FabricRecipeProvider.conditionsFromItem(SIMPLE_BLOCK)).offerTo(exporter); 
 +
 +</code> 
 + 
 +===== Adding A Shaped Recipe ===== 
 +In this example, we will create a shaped recipe where a stone block is crafted from ''EXAMPLE_ITEM''s and ''EXAMPLE_BLOCK''s. 
 + 
 +<code java> 
 +public static Block SIMPLE_BLOCK = Registry.register(Registry.BLOCK, new Identifier("mymod", "simple_block"), new Block(...)); 
 +public static BlockItem SIMPLE_ITEM = Registry.register(Registry.ITEM, new Identifier("mymod", "simple_item"), new Item(...)); 
 +// ... 
 + 
 +@Override 
 +protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) { 
 +          ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, Blocks.STONE_BLOCK).pattern("bbb").pattern("iii"
 +                .input('b', SIMPLE_BLOCK) 
 +                .input('i', SIMPLE_ITEM) 
 +                .criterion(FabricRecipeProvider.hasItem(SIMPLE_ITEM), 
 +                        FabricRecipeProvider.conditionsFromItem(SIMPLE_ITEM)) 
 +                .criterion(FabricRecipeProvider.hasItem(SIMPLE_BLOCK), 
 +                        FabricRecipeProvider.conditionsFromItem(SIMPLE_BLOCK)) 
 +                .offerTo(exporter);
 } }
 </code> </code>
tutorial/datagen_recipe.1685987224.txt.gz · Last modified: 2023/06/05 17:47 by mcrafterzz