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
Last revisionBoth sides next revision
tutorial:datagen_setup [2023/10/10 14:49] – Missing word in first section haykamtutorial:datagen_setup [2024/03/15 05:05] shnupbups
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.txt · Last modified: 2024/03/15 05:06 by shnupbups