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 [2025/03/25 00:41] (current) – [IDE Integration (Optional)] removed the section solidblock
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> </code>
  
-Next find the ''**loom**'' section in that very same file ''**build.gradle**'' and add the following inside it:+If you're using version 1.21.4 or above, please replace the ''fabricApi'' section in the code above with the following:
  
-<code groovy gradle.build [highlight_lines_extra="9,10,11,12,13,14,15,16,17,18,19,20"]+<code groovy> 
- +fabricApi 
-// +    configureDataGeneration() { 
-// ... (The rest of the file) +        client true
-// +
- +
-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 138: Line 100:
 There should be a new folder in ''**src/main**'' called ''**generated**''. For now it'll be empty, but once we start generating data (like advancements), that is where it'll be saved. There should be a new folder in ''**src/main**'' called ''**generated**''. For now it'll be empty, but once we start generating data (like advancements), that is where it'll be saved.
  
-==== IDE Integration (Optional) ==== 
- 
-Because we don't want to be opening the terminal all the time, we can setup a configuration in ''**IntelljJ IDEA**'' that will run the command for us through a drop-down menu.  
- 
-First open the ''**Run/Debug Configurations**'' menu. You can open it by opening the drop-down menu next to the run button and clicking ''**Edit Configurations..**'' option or you can double click ''**Shift**'' and type ''**Edit Configuration**'' into the menu that pops up. 
- 
-Next click the ''**'+'**'' button, search for ''**gradle**'', and select it. 
- 
-Inside the ''**Run**'' textbox write ''**runDatagen**''. Click ''**Okay**'' and you should be able to simply run the configuration instead of having to open the terminal. 
  
 ====== Adding Providers ====== ====== Adding Providers ======
Line 163: Line 116:
 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