1
1
plugins {
2
+ id ' java-library'
2
3
id ' eclipse'
3
4
id ' idea'
4
5
id ' maven-publish'
5
- id ' net.neoforged.gradle' version ' [6.0.18,6.2)'
6
- id ' org.spongepowered.mixin' version ' 0.7-SNAPSHOT'
6
+ id ' net.neoforged.gradle.userdev' version ' [7.0.5,)'
7
+ id ' net.neoforged.gradle.mixin' version ' [7.0.5,)'
8
+ id " com.modrinth.minotaur" version " 2.+"
7
9
}
8
10
9
- apply plugin : " net.neoforged.gradle"
10
- // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
11
- apply plugin : ' eclipse'
12
- apply plugin : ' maven-publish'
13
- apply plugin : " org.spongepowered.mixin"
14
-
15
11
version = mod_version
16
12
group = mod_group_id
17
13
14
+ repositories {
15
+ mavenLocal()
16
+ }
17
+
18
18
base {
19
19
archivesName = mod_id
20
20
}
21
21
22
22
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
23
23
java. toolchain. languageVersion = JavaLanguageVersion . of(17 )
24
24
25
- println " Java: ${ System.getProperty 'java.version'} , JVM: ${ System.getProperty 'java.vm.version'} (${ System.getProperty 'java.vendor'} ), Arch: ${ System.getProperty 'os.arch'} "
26
- minecraft {
27
- // The mappings can be changed at any time and must be in the following format.
28
- // Channel: Version:
29
- // official MCVersion Official field/method names from Mojang mapping files
30
- // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
31
- //
32
- // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
33
- // See more information here: https://github.com/NeoForged/NeoForm/blob/main/Mojang.md
34
- //
35
- // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
36
- // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
37
- //
38
- // Use non-default mappings at your own risk. They may not always work.
39
- // Simply re-run your setup task after changing the mappings to update your workspace.
40
- mappings channel : mapping_channel, version : mapping_version
41
-
42
- // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
43
- // In most cases, it is not necessary to enable.
44
- // enableEclipsePrepareRuns = true
45
- enableIdeaPrepareRuns = true
46
-
47
- // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
48
- // It is REQUIRED to be set to true for this template to function.
49
- // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
50
- copyIdeResources = true
51
-
52
- // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
53
- // The folder name can be set on a run configuration using the "folderName" property.
54
- // By default, the folder name of a run configuration is the name of the Gradle project containing it.
55
- // generateRunFolders = true
56
-
57
- // This property enables access transformers for use in development.
58
- // They will be applied to the Minecraft artifact.
59
- // The access transformer file can be anywhere in the project.
60
- // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
61
- // This default location is a best practice to automatically put the file in the right place in the final jar.
62
- // See https://docs.neoforged.net/docs/1.20.x/advanced/accesstransformers/ for more information.
63
-
64
- accessTransformer = file(' src/main/resources/META-INF/accesstransformer.cfg' )
65
-
66
- // Default run configurations.
67
- // These can be tweaked, removed, or duplicated as needed.
68
- runs {
69
- // applies to all the run configs below
70
- configureEach {
71
- workingDirectory project. file(' run' )
72
-
73
- // Recommended logging data for a userdev environment
74
- // The markers can be added/remove as needed separated by commas.
75
- // "SCAN": For mods scan.
76
- // "REGISTRIES": For firing of registry events.
77
- // "REGISTRYDUMP": For getting the contents of all registries.
78
- property ' forge.logging.markers' , ' REGISTRIES'
79
-
80
- // Recommended logging level for the console
81
- // You can set various levels here.
82
- // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
83
- property ' forge.logging.console.level' , ' debug'
84
- property " mixin.env.remapRefMap" , " true"
85
- mods {
86
- " ${ mod_id} " {
87
- source sourceSets. main
88
- }
89
- }
90
- }
25
+ minecraft. accessTransformers. file rootProject. file(' src/main/resources/META-INF/accesstransformer.cfg' )
26
+ // Default run configurations.
27
+ // These can be tweaked, removed, or duplicated as needed.
28
+ runs {
29
+ // applies to all the run configs below
30
+ configureEach {
31
+ // Recommended logging data for a userdev environment
32
+ // The markers can be added/remove as needed separated by commas.
33
+ // "SCAN": For mods scan.
34
+ // "REGISTRIES": For firing of registry events.
35
+ // "REGISTRYDUMP": For getting the contents of all registries.
36
+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
37
+
38
+ // Recommended logging level for the console
39
+ // You can set various levels here.
40
+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
41
+ systemProperty ' forge.logging.console.level' , ' debug'
42
+
43
+ modSource project. sourceSets. main
44
+ }
91
45
92
- client {
93
- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
94
- property ' forge.enabledGameTestNamespaces' , mod_id
95
- }
46
+ client {
47
+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
48
+ systemProperty ' forge.enabledGameTestNamespaces' , project . mod_id
49
+ }
96
50
97
- server {
98
- property ' forge.enabledGameTestNamespaces' , mod_id
99
- args ' --nogui'
100
- }
51
+ server {
52
+ systemProperty ' forge.enabledGameTestNamespaces' , project . mod_id
53
+ programArgument ' --nogui'
54
+ }
101
55
102
- // This run config launches GameTestServer and runs all registered gametests, then exits.
103
- // By default, the server will crash when no gametests are provided.
104
- // The gametest system is also enabled by default for other run configs under the /test command.
105
- gameTestServer {
106
- property ' forge.enabledGameTestNamespaces' , mod_id
107
- }
56
+ // This run config launches GameTestServer and runs all registered gametests, then exits.
57
+ // By default, the server will crash when no gametests are provided.
58
+ // The gametest system is also enabled by default for other run configs under the /test command.
59
+ gameTestServer {
60
+ systemProperty ' forge.enabledGameTestNamespaces' , project . mod_id
61
+ }
108
62
109
- data {
110
- // example of overriding the workingDirectory set in configureEach above
111
- workingDirectory project. file(' run-data' )
63
+ data {
64
+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
65
+ // workingDirectory project.file('run-data')
112
66
113
- // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
114
- args ' --mod' , mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ), ' --existing' , file(' src/main/resources/' )
115
- }
67
+ // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
68
+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
116
69
}
117
70
}
118
71
119
- // Include resources generated by data generators.
120
- sourceSets. main. resources { srcDir ' src/generated/resources' }
121
-
122
72
repositories {
123
- // Put repositories for dependencies here
124
- // NeoGradle automatically adds the Forge maven and Maven Central for you
125
-
126
- // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
127
- // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
128
- // flatDir {
129
- // dir 'libs'
130
- // }
131
73
maven {
132
74
url = " https://api.modrinth.com/maven"
133
75
}
134
76
}
135
77
78
+ // Include resources generated by data generators.
79
+ sourceSets. main. resources { srcDir ' src/generated/resources' }
80
+
136
81
dependencies {
137
82
// Specify the version of Minecraft to use.
138
83
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
139
84
// The "userdev" classifier will be requested and setup by NeoGradle.
140
85
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
141
86
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
142
- minecraft " net.neoforged:forge: ${ minecraft_version } - ${ neo_version} "
87
+ implementation " net.neoforged:neoforge: ${ neo_version} "
143
88
annotationProcessor " org.spongepowered:mixin:0.8.5:processor"
89
+ implementation " maven.modrinth:bagus-lib:1.20.2-6.0.1"
144
90
// Example mod dependency using a mod jar from ./libs with a flat dir repository
145
91
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
146
92
// The group id is ignored when searching -- in this case, it is "blank"
147
93
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
148
- implementation(fg . deobf( " maven.modrinth:bagus-lib: ${ bagus_lib_version } " ))
94
+
149
95
// For more info:
150
96
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
151
97
// http://www.gradle.org/docs/current/userguide/dependency_management.html
152
98
}
153
99
154
100
// This block of code expands all declared replace properties in the specified resource targets.
155
- // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
101
+ // A missing systemProperty will result in an error. Properties are expanded using ${} Groovy notation.
156
102
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
157
103
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
158
- tasks. named( ' processResources ' , ProcessResources ). configure {
104
+ tasks. withType( ProcessResources ). configureEach {
159
105
var replaceProperties = [
160
106
minecraft_version : minecraft_version, minecraft_version_range : minecraft_version_range,
161
107
neo_version : neo_version, neo_version_range : neo_version_range,
162
108
loader_version_range : loader_version_range,
163
109
mod_id : mod_id, mod_name : mod_name, mod_license : mod_license, mod_version : mod_version,
164
110
mod_authors : mod_authors, mod_description : mod_description, pack_format_number : pack_format_number,
165
- bagus_lib_version : bagus_lib_version, bagus_lib_version_range : bagus_lib_version_range
111
+ mod_credits : mod_credits,
166
112
]
167
113
inputs. properties replaceProperties
168
114
@@ -171,43 +117,28 @@ tasks.named('processResources', ProcessResources).configure {
171
117
}
172
118
}
173
119
174
- // Example for how to get properties into the manifest for reading at runtime.
175
- tasks. named(' jar' , Jar ). configure {
176
- manifest {
177
- attributes([
178
- ' Specification-Title' : mod_id,
179
- ' Specification-Vendor' : mod_authors,
180
- ' Specification-Version' : ' 1' , // We are version 1 of ourselves
181
- ' Implementation-Title' : project. name,
182
- ' Implementation-Version' : project. jar. archiveVersion,
183
- ' Implementation-Vendor' : mod_authors,
184
- ' Implementation-Timestamp' : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
185
- ])
186
- }
187
-
188
- // This is the preferred method to reobfuscate your jar file
189
- finalizedBy ' reobfJar'
190
- }
191
-
192
- // 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:
193
- // tasks.named('publish').configure {
194
- // dependsOn 'reobfJar'
195
- // }
196
-
197
120
// Example configuration to allow publishing using the maven-publish plugin
198
121
publishing {
199
122
publications {
200
123
register(' mavenJava' , MavenPublication ) {
201
- artifact jar
124
+ from components . java
202
125
}
203
126
}
204
127
repositories {
205
128
maven {
206
- url " file://${ project.projectDir} /mcmodsrepo "
129
+ url " file://${ project.projectDir} /repo "
207
130
}
208
131
}
209
132
}
210
133
211
134
tasks. withType(JavaCompile ). configureEach {
212
135
options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
136
+ }
137
+
138
+ if (System . getProperty(" idea.sync.active" ) == " true" ) {
139
+ afterEvaluate {
140
+ tasks. withType(JavaCompile ). all {
141
+ it. options. annotationProcessorPath = files()
142
+ }
143
+ }
213
144
}
0 commit comments