11plugins {
2+ id ' java-library'
23 id ' eclipse'
34 id ' idea'
45 id ' maven-publish'
5- id ' net.minecraftforge .gradle' version ' [6.0,6.2) '
6- id ' org.parchmentmc.librarian.forgegradle' version ' 1.+'
6+ id ' net.neoforged .gradle.userdev ' version ' 7.0.5 '
7+ // id 'org.parchmentmc.librarian.forgegradle' version '1.+'
78}
89
910version = mod_version
1011group = mod_group_id
1112
13+ repositories {
14+ mavenLocal()
15+ }
16+
1217base {
1318 archivesName = mod_id
1419}
1520
1621// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
1722java. toolchain. languageVersion = JavaLanguageVersion . of(17 )
1823
19- println " Java: ${ System.getProperty 'java.version'} , JVM: ${ System.getProperty 'java.vm.version'} (${ System.getProperty 'java.vendor'} ), Arch: ${ System.getProperty 'os.arch'} "
20- minecraft {
21- // The mappings can be changed at any time and must be in the following format.
22- // Channel: Version:
23- // official MCVersion Official field/method names from Mojang mapping files
24- // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
25- //
26- // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
27- // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
28- //
29- // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
30- // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
31- //
32- // Use non-default mappings at your own risk. They may not always work.
33- // Simply re-run your setup task after changing the mappings to update your workspace.
34- mappings channel : mapping_channel, version : mapping_version
35-
36- // When true, this property will have all Eclipse run configurations run the "prepareX" task for the given run configuration before launching the game.
37- // In most cases, it is not necessary to enable.
38- // enableEclipsePrepareRuns = true
39-
40- // When true, this property will have all IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
41- // In most cases, it is not necessary to enable.
42- // enableIdeaPrepareRuns = true
43-
44- // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
45- // It is REQUIRED to be set to true for this template to function.
46- // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
47- copyIdeResources = true
48-
49- // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
50- // The folder name can be set on a run configuration using the "folderName" property.
51- // By default, the folder name of a run configuration is the name of the Gradle project containing it.
52- // generateRunFolders = true
53-
54- // This property enables access transformers for use in development.
55- // They will be applied to the Minecraft artifact.
56- // The access transformer file can be anywhere in the project.
57- // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
58- // This default location is a best practice to automatically put the file in the right place in the final jar.
59- // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
60- // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
61-
62- // Default run configurations.
63- // These can be tweaked, removed, or duplicated as needed.
64- runs {
65- client {
66- workingDirectory project. file(' run' )
67-
68- // Recommended logging data for a userdev environment
69- // The markers can be added/remove as needed separated by commas.
70- // "SCAN": For mods scan.
71- // "REGISTRIES": For firing of registry events.
72- // "REGISTRYDUMP": For getting the contents of all registries.
73- property ' forge.logging.markers' , ' REGISTRIES'
74-
75- // Recommended logging level for the console
76- // You can set various levels here.
77- // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
78- property ' forge.logging.console.level' , ' debug'
79-
80- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
81- property ' forge.enabledGameTestNamespaces' , mod_id
82-
83- mods {
84- " ${ mod_id} " {
85- source sourceSets. main
86- }
87- }
88- }
89-
90- server {
91- workingDirectory project. file(' run' )
92-
93- property ' forge.logging.markers' , ' REGISTRIES'
94-
95- property ' forge.logging.console.level' , ' debug'
96-
97- property ' forge.enabledGameTestNamespaces' , mod_id
98-
99- mods {
100- " ${ mod_id} " {
101- source sourceSets. main
102- }
103- }
104- }
105-
106- // This run config launches GameTestServer and runs all registered gametests, then exits.
107- // By default, the server will crash when no gametests are provided.
108- // The gametest system is also enabled by default for other run configs under the /test command.
109- gameTestServer {
110- workingDirectory project. file(' run' )
111-
112- property ' forge.logging.markers' , ' REGISTRIES'
113-
114- property ' forge.logging.console.level' , ' debug'
115-
116- property ' forge.enabledGameTestNamespaces' , mod_id
117-
118- mods {
119- " ${ mod_id} " {
120- source sourceSets. main
121- }
122- }
123- }
24+ // minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
25+ // minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
26+
27+ // Default run configurations.
28+ // These can be tweaked, removed, or duplicated as needed.
29+ runs {
30+ // applies to all the run configs below
31+ configureEach {
32+ // Recommended logging data for a userdev environment
33+ // The markers can be added/remove as needed separated by commas.
34+ // "SCAN": For mods scan.
35+ // "REGISTRIES": For firing of registry events.
36+ // "REGISTRYDUMP": For getting the contents of all registries.
37+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
38+
39+ // Recommended logging level for the console
40+ // You can set various levels here.
41+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
42+ systemProperty ' forge.logging.console.level' , ' debug'
43+
44+ modSource project. sourceSets. main
45+ }
12446
125- data {
126- workingDirectory project. file(' run' )
47+ client {
48+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
49+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
50+ }
12751
128- property ' forge.logging.markers' , ' REGISTRIES'
52+ server {
53+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
54+ programArgument ' --nogui'
55+ }
12956
130- property ' forge.logging.console.level' , ' debug'
57+ // This run config launches GameTestServer and runs all registered gametests, then exits.
58+ // By default, the server will crash when no gametests are provided.
59+ // The gametest system is also enabled by default for other run configs under the /test command.
60+ gameTestServer {
61+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
62+ }
13163
132- // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
133- args ' --mod' , mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ), ' --existing' , file(' src/main/resources/' )
64+ data {
65+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
66+ // workingDirectory project.file('run-data')
13467
135- mods {
136- " ${ mod_id} " {
137- source sourceSets. main
138- }
139- }
140- }
68+ // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
69+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
14170 }
14271}
14372
14473// Include resources generated by data generators.
14574sourceSets. main. resources { srcDir ' src/generated/resources' }
14675
147- repositories {
148- // Put repositories for dependencies here
149- // ForgeGradle automatically adds the Forge maven and Maven Central for you
150-
151- // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
152- // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
153- // flatDir {
154- // dir 'libs'
155- // }
156- }
15776
15877dependencies {
15978 // Specify the version of Minecraft to use.
160- // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
161- // The "userdev" classifier will be requested and setup by ForgeGradle.
162- // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
163- // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
164- minecraft " net.minecraftforge:forge:${ minecraft_version} -${ forge_version} "
165-
166- // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
79+ // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
80+ // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
81+ // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
82+ // 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.
83+ // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
84+ implementation " net.neoforged:neoforge:${ neo_version} "
85+
86+ // Example mod dependency with JEI
16787 // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
168- // compileOnly fg.deobf( "mezz.jei:jei-${mc_version}-common-api:${jei_version}")
169- // compileOnly fg.deobf( "mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
170- // runtimeOnly fg.deobf( "mezz.jei:jei-${mc_version}-forge:${jei_version}")
88+ // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
89+ // compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
90+ // runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
17191
17292 // Example mod dependency using a mod jar from ./libs with a flat dir repository
17393 // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
17494 // The group id is ignored when searching -- in this case, it is "blank"
175- // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
95+ // implementation "blank:coolmod-${mc_version}:${coolmod_version}"
96+
97+ // Example mod dependency using a file as dependency
98+ // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
99+
100+ // Example project dependency using a sister or child project:
101+ // implementation project(":myproject")
176102
177103 // For more info:
178104 // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
@@ -183,57 +109,35 @@ dependencies {
183109// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
184110// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
185111// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
186- def resourceTargets = [' META-INF/mods.toml' , ' pack.mcmeta' ]
187- def replaceProperties = [
188- minecraft_version : minecraft_version, minecraft_version_range : minecraft_version_range,
189- forge_version : forge_version, forge_version_range : forge_version_range,
190- loader_version_range : loader_version_range,
191- mod_id : mod_id, mod_name : mod_name, mod_license : mod_license, mod_version : mod_version,
192- mod_authors : mod_authors, mod_description : mod_description
193- ]
194- processResources {
112+ tasks. withType(ProcessResources ). configureEach {
113+ var replaceProperties = [
114+ minecraft_version : minecraft_version, minecraft_version_range : minecraft_version_range,
115+ neo_version : neo_version, neo_version_range : neo_version_range,
116+ loader_version_range : loader_version_range,
117+ mod_id : mod_id, mod_name : mod_name, mod_license : mod_license, mod_version : mod_version,
118+ mod_authors : mod_authors, mod_description : mod_description, pack_format_number : pack_format_number,
119+ ]
195120 inputs. properties replaceProperties
196- replaceProperties. put ' project' , project
197121
198- filesMatching(resourceTargets) {
199- expand replaceProperties
200- }
201- }
202-
203- // Example for how to get properties into the manifest for reading at runtime.
204- jar {
205- manifest {
206- attributes([
207- " Specification-Title" : mod_id,
208- " Specification-Vendor" : mod_authors,
209- " Specification-Version" : " 2" , // We are version 1 of ourselves
210- " Implementation-Title" : project. name,
211- " Implementation-Version" : project. jar. archiveVersion,
212- " Implementation-Vendor" : mod_authors,
213- " Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
214- ])
122+ filesMatching([' META-INF/mods.toml' , ' pack.mcmeta' ]) {
123+ expand replaceProperties + [project : project]
215124 }
216125}
217126
218127// Example configuration to allow publishing using the maven-publish plugin
219- // This is the preferred method to reobfuscate your jar file
220- jar. finalizedBy(' reobfJar' )
221- // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
222- // publish.dependsOn('reobfJar')
223-
224128publishing {
225129 publications {
226- mavenJava( MavenPublication ) {
227- artifact jar
130+ register( ' mavenJava ' , MavenPublication ) {
131+ from components . java
228132 }
229133 }
230134 repositories {
231135 maven {
232- url " file://${ project.projectDir} /mcmodsrepo "
136+ url " file://${ project.projectDir} /repo "
233137 }
234138 }
235139}
236140
237141tasks. withType(JavaCompile ). configureEach {
238142 options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
239- }
143+ }
0 commit comments