11plugins {
22 id ' java-library'
3- id ' eclipse'
4- id ' idea'
53 id ' maven-publish'
6- id ' net.neoforged.gradle.userdev' version ' 7.0.142'
4+ id ' net.neoforged.moddev' version ' 2.0.134'
5+ id ' idea'
6+ }
7+
8+ tasks. named(' wrapper' , Wrapper ). configure {
9+ // Define wrapper values here so as to not have to always do so when updating gradlew.properties.
10+ // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
11+ // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
12+ // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
13+ // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
14+ distributionType = Wrapper.DistributionType . BIN
715}
816
917def getVersionFromFile () {
@@ -29,55 +37,78 @@ base {
2937 archivesName = file_name
3038}
3139
32- // Mojang ships Java 21 to end users starting in 1.20.5 , so mods should target Java 21.
40+ // Mojang ships Java 21 to end users in 1.21 , so mods should target Java 21.
3341java. toolchain. languageVersion = JavaLanguageVersion . of(21 )
3442
35- // minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
36- // minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
37-
38- // Default run configurations.
39- // These can be tweaked, removed, or duplicated as needed.
40- runs {
41- // applies to all the run configs below
42- configureEach {
43- // Recommended logging data for a userdev environment
44- // The markers can be added/remove as needed separated by commas.
45- // "SCAN": For mods scan.
46- // "REGISTRIES": For firing of registry events.
47- // "REGISTRYDUMP": For getting the contents of all registries.
48- systemProperty ' forge.logging.markers' , ' REGISTRIES'
49-
50- // Recommended logging level for the console
51- // You can set various levels here.
52- // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
53- systemProperty ' forge.logging.console.level' , ' debug'
54-
55- modSource project. sourceSets. main
56- }
43+ neoForge {
44+ // Specify the version of NeoForge to use.
45+ version = project. neo_version
5746
58- client {
59- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
60- systemProperty ' forge.enabledGameTestNamespaces ' , project. mod_id
47+ parchment {
48+ mappingsVersion = project . parchment_mappings_version
49+ minecraftVersion = project. parchment_minecraft_version
6150 }
6251
63- server {
64- systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
65- programArgument ' --nogui'
66- }
52+ // This line is optional. Access Transformers are automatically detected
53+ // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
6754
68- // This run config launches GameTestServer and runs all registered gametests, then exits.
69- // By default, the server will crash when no gametests are provided.
70- // The gametest system is also enabled by default for other run configs under the /test command.
71- gameTestServer {
72- systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
73- }
55+ // Default run configurations.
56+ // These can be tweaked, removed, or duplicated as needed.
57+ runs {
58+ client {
59+ client()
60+
61+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
62+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
63+ }
64+
65+ server {
66+ server()
67+ programArgument ' --nogui'
68+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
69+ }
70+
71+ // This run config launches GameTestServer and runs all registered gametests, then exits.
72+ // By default, the server will crash when no gametests are provided.
73+ // The gametest system is also enabled by default for other run configs under the /test command.
74+ gameTestServer {
75+ type = " gameTestServer"
76+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
77+ }
78+
79+ data {
80+ data()
7481
75- data {
76- // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
77- // workingDirectory project.file('run-data')
82+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
83+ // gameDirectory = project.file('run-data')
7884
79- // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
80- programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
85+ // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
86+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
87+ }
88+
89+ // applies to all the run configs above
90+ configureEach {
91+ // Recommended logging data for a userdev environment
92+ // The markers can be added/remove as needed separated by commas.
93+ // "SCAN": For mods scan.
94+ // "REGISTRIES": For firing of registry events.
95+ // "REGISTRYDUMP": For getting the contents of all registries.
96+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
97+
98+ // Recommended logging level for the console
99+ // You can set various levels here.
100+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
101+ logLevel = org.slf4j.event.Level . DEBUG
102+ }
103+ }
104+
105+ mods {
106+ // define mod <-> source bindings
107+ // these are used to tell the game which sources are for which mod
108+ // multi mod projects should define one per mod
109+ " ${ mod_id} " {
110+ sourceSet(sourceSets. main)
111+ }
81112 }
82113}
83114
@@ -93,20 +124,6 @@ configurations {
93124}
94125
95126dependencies {
96- // Specify the version of Minecraft to use.
97- // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
98- // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
99- // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
100- // And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
101- // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
102- implementation " net.neoforged:neoforge:${ neo_version} "
103-
104- implementation(' com.squareup.okhttp3:okhttp:5.3.2' )
105- implementation(' com.squareup.okio:okio-jvm:3.16.4' )
106-
107- jarJar(group : ' com.squareup.okhttp3' , name : ' okhttp' , version : ' [5.3.2,6.0)' )
108- jarJar(group : ' com.squareup.okio' , name : ' okio-jvm' , version : ' [3.16.4,4.0)' )
109-
110127 // Example optional mod dependency with JEI
111128 // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
112129 // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
@@ -128,32 +145,37 @@ dependencies {
128145 // For more info:
129146 // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
130147 // http://www.gradle.org/docs/current/userguide/dependency_management.html
148+
149+ implementation(' org.apache.httpcomponents.client5:httpclient5:5.6' )
150+
151+ jarJar(group : ' org.apache.httpcomponents.client5' , name : ' httpclient5' , version : ' [5.6,6.0)' )
152+ jarJar(group : ' org.apache.httpcomponents.core5' , name : ' httpcore5' , version : ' [5.4,6.0)' )
153+ jarJar(group : ' org.apache.httpcomponents.core5' , name : ' httpcore5-h2' , version : ' [5.4,6.0)' )
131154}
132155
133156// This block of code expands all declared replace properties in the specified resource targets.
134157// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
135- // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
136- // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
137- tasks. withType(ProcessResources ). configureEach {
158+ var generateModMetadata = tasks. register(" generateModMetadata" , ProcessResources ) {
138159 var replaceProperties = [
139160 minecraft_version : minecraft_version,
140161 minecraft_version_range : minecraft_version_range,
141162 neo_version : neo_version,
142- neo_version_range : neo_version_range,
143163 loader_version_range : loader_version_range,
144164 mod_id : mod_id,
145165 mod_name : mod_name,
146166 mod_license : mod_license,
147167 mod_version : mod_version,
148- mod_authors : mod_authors,
149- mod_description : mod_description
150168 ]
151169 inputs. properties replaceProperties
152-
153- filesMatching([' META-INF/neoforge.mods.toml' ]) {
154- expand replaceProperties
155- }
170+ expand replaceProperties
171+ from " src/main/templates"
172+ into " build/generated/sources/modMetadata"
156173}
174+ // Include the output of "generateModMetadata" as an input directory for the build
175+ // this works with both building through Gradle and the IDE.
176+ sourceSets. main. resources. srcDir generateModMetadata
177+ // To avoid having to run "generateModMetadata" manually, make it run on every project reload
178+ neoForge. ideSyncTask generateModMetadata
157179
158180// Example configuration to allow publishing using the maven-publish plugin
159181publishing {
@@ -179,4 +201,4 @@ idea {
179201 downloadSources = true
180202 downloadJavadoc = true
181203 }
182- }
204+ }
0 commit comments