User Tools

Site Tools


tutorial:datagen_setup

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_setup [2023/09/29 07:44] jmanc3tutorial:datagen_setup [2024/03/15 05:06] (current) shnupbups
Line 1: Line 1:
 ====== Getting started with Data Generation ====== ====== Getting started with Data Generation ======
  
-Data Generation is a of Fabric API which allows you to programmatically generate Recipes, Language Files, Loot Tables, Advancements and pretty much anything with Custom Providers. Every time you modify the code that generates advancements (or anything else datagen can make like loot tables and such) you'll have to run the gradle task ''**runDatagen**'' which we will create shortly.+Data Generation is a module of Fabric API which allows you to programmatically generate Recipes, Language Files, Loot Tables, Advancements and pretty much anything with Custom Providers. Every time you modify the code that generates advancements (or anything else datagen can make like loot tables and such) you'll have to run the gradle task ''**runDatagen**'' which we will create shortly.
    
 ===== Enabling Data Generation ===== ===== Enabling Data Generation =====
Line 15: Line 15:
 First open up your ''**build.gradle**'' file in the root folder of your project, and add the following anywhere inside that file: First open up your ''**build.gradle**'' file in the root folder of your project, and add the following anywhere inside that file:
  
-<code groovy gradle.build [highlight_lines_extra="5,6,7,8,9,10,11,12,13"]>+<code groovy build.gradle [highlight_lines_extra="5,6,7"]>
  
 // //
Line 21: Line 21:
 // //
  
-sourceSets +fabricApi 
-    main { +    configureDataGeneration()
-        resources { +
-            srcDirs += [ +
-                    'src/main/generated' +
-            ] +
-        } +
-    }+
 } }
-</code> 
- 
-Next find the ''**loom**'' section in that very same file ''**build.gradle**'' and add the following inside it: 
- 
-<code groovy gradle.build [highlight_lines_extra="9,10,11,12,13,14,15,16,17,18,19,20"]> 
- 
-// 
-// ... (The rest of the file) 
-// 
- 
-loom { 
- 
-    // ... (Whatever exists here) 
- 
-    runs { 
-        // This adds a new gradle task that runs the datagen API: "gradlew runDatagen" 
-        datagen { 
-            inherit server 
-            name "Data Generation" 
-            vmArg "-Dfabric-api.datagen" 
-            vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}" 
-            vmArg "-Dfabric-api.datagen.modid=${modid}" 
-  
-            runDir "build/datagen" 
-        } 
-    } 
-} 
- 
-// ... (The rest of the file) 
- 
-</code> 
- 
-  * NOTE: You may have to change the line ''**inherit server**'' to ''**inherit client**'' in some cases. 
- 
-You'll notice the code we just added to the ''**loom**'' section makes use of the variable ''**${modid}**''. That should be defined in the ''**gradle.properties**'' file. Check and see if you have that variable already defined inside that file, and if not, you can add it like this: 
- 
-<code properties gradle.properties> 
-// .. (The rest of the file) 
- 
-modid=the-name-of-your-mod-change-me-please 
- 
-// .. (The rest of the file) 
 </code> </code>
  
Line 163: Line 115:
 Firstly, inside your ''**ExampleModDataGenerator**'' class, create a new ''**private static class**'' that extends ''**FabricTagProvider<T>**'': Firstly, inside your ''**ExampleModDataGenerator**'' class, create a new ''**private static class**'' that extends ''**FabricTagProvider<T>**'':
  
-//If you want, you can place this class in a seperate file, but we recommend it stays in your datagen entrypoint class.//+//If you want, you can place this class in a separate file, but we recommend it stays in your datagen entrypoint class.//
  
 <code java> <code java>
tutorial/datagen_setup.1695973471.txt.gz · Last modified: 2023/09/29 07:44 by jmanc3