User Tools

Site Tools


tutorial:cooking_recipe_type

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
Next revisionBoth sides next revision
cooking_recipe_type [2020/12/17 20:44] – fixed a typo error legoreltutorial:cooking_recipe_type [2021/01/26 12:55] ytg1234
Line 4: Line 4:
  
 Creating a cooking recipe type is just like creating a custom recipe type with extra steps. Vanilla minecraft has abstracts classes for furnaces and cooking recipe type so we'll use them to save some time and code! Creating a cooking recipe type is just like creating a custom recipe type with extra steps. Vanilla minecraft has abstracts classes for furnaces and cooking recipe type so we'll use them to save some time and code!
-If it is your first time creating a container block you should go check this tutorial before: https://fabricmc.net/wiki/tutorial:screenhandler+If it is your first time creating a container block you should go check this tutorial before: [[tutorial:screenhandler]]
  
 The final result of this tutorial can be found here: https://github.com/Legorel/CookingRecipeExample The final result of this tutorial can be found here: https://github.com/Legorel/CookingRecipeExample
Line 124: Line 124:
 ===== Creating the recipe serializer ===== ===== Creating the recipe serializer =====
  
-This is where it get different from a normal recipe type, you can make your own serializer if your furnace works differently from vanilla one or just register a new ''CookingRecipeSerializer'' to save some code :+This is where it gets different from a normal recipe type, you can make your own serializer if your furnace works differently from vanilla one or just register a new ''CookingRecipeSerializer'' to save some code :
  
 <code java CookingRecipeExample.java> <code java CookingRecipeExample.java>
Line 133: Line 133:
     static {     static {
         [...]         [...]
-        TEST_RECIPE_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(MOD_ID, "test_furnace"), new CookingRecipeSerializer(TestRecipe::new, 200)); +        TEST_RECIPE_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(MODID, "test_furnace"), new CookingRecipeSerializer<>(TestRecipe::new, 200));
-        +
     }     }
 } }
 </code> </code>
  
-There is just one problem, ''CookingRecipeSerializer'' uses an interface ''RecipeFactory'' that we don't have access to. We could just make our own serializer but this will mean that we couldn't use the classes like ''AbstractFurnaceBlockEntity'' because of some ''Generic Types''. To counter this we will use an ''Access Widener'' to get access to the interface. The tutorial on ''Access Widener'' can be found here : https://fabricmc.net/wiki/tutorial:accesswideners+There is just one problem, ''CookingRecipeSerializer'' uses an interface ''RecipeFactory'' that we don't have access to. We could just make our own serializer but this will mean that we couldn't use the classes like ''AbstractFurnaceBlockEntity'' because of some ''Generic Types''. To counter this we will use an ''Access Widener'' to get access to the interface. The tutorial on ''Access Widener'' can be found here : [[tutorial:accesswideners]]
  
  
Line 235: Line 234:
 ===== Adding a recipe ===== ===== Adding a recipe =====
 Now it is the time to test our recipe type, before continuing you should make sure that every class we created is imported in the classes where they are used. Now it is the time to test our recipe type, before continuing you should make sure that every class we created is imported in the classes where they are used.
-To create our recipe we can follow the official way: https://minecraft.gamepedia.com/Recipe#JSON_format+To create our recipe we simply follow the official way: https://minecraft.gamepedia.com/Recipe#JSON_format
  
   Recipe path: .../src/main/resources/data/modid/recipes/test_recipe.json   Recipe path: .../src/main/resources/data/modid/recipes/test_recipe.json
Line 254: Line 253:
  
 ===== Next step ===== ===== Next step =====
-We have our recipe type, our furnace, but no textures for our block. You can learn how to add visuals to your block here : https://fabricmc.net/wiki/tutorial:blocks#giving_your_block_visuals+We have our recipe type, our furnace, but no textures for our block. You can learn how to add visuals to your block here : [[tutorial:blocks#giving_your_block_visuals]]
  
-But don't forget that we extended ''AbstractFurnaceBlock'', this mean our block already have 2 ''BlockState'', one for the direction it is facing and the other for when it is lit or not. You can find a tutorial on ''BlockStates'' here: https://fabricmc.net/wiki/tutorial:blockstate#adding_models_for_your_blockstates.+But don't forget that we extended ''AbstractFurnaceBlock'', this mean our block already have 2 ''BlockState'', one for the direction it is facing and the other for when it is lit or not. You can find a tutorial on ''BlockStates'' here: [[tutorial:blockstate#adding_models_for_your_blockstates]]
  
 Just in case, i'll put the furnace blockstates file as an example: Just in case, i'll put the furnace blockstates file as an example:
tutorial/cooking_recipe_type.txt · Last modified: 2022/02/07 12:40 by 127.0.0.1