1
1
plugins {
2
- id ' java-library'
3
- id ' eclipse'
4
- id ' idea'
5
- id ' maven-publish'
6
- id ' net.neoforged.gradle.userdev' version ' 7.0.170'
2
+ id ' java-library'
3
+ id ' maven-publish'
4
+ id ' io.github.0ffz.github-packages' version ' [1,2)'
5
+ id ' net.neoforged.moddev' version ' 1.0.23'
7
6
}
8
7
9
8
tasks. named(' wrapper' , Wrapper ). configure {
10
- // Define wrapper values here so as to not have to always do so when updating gradlew.properties.
11
- // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
12
- // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
13
- // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
14
- // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
15
9
distributionType = Wrapper.DistributionType . BIN
16
10
}
17
11
@@ -25,73 +19,61 @@ repositories {
25
19
url = " https://api.modrinth.com/maven"
26
20
}
27
21
maven {
28
- url = " https://modmaven.dev"
29
- }
22
+ url = " https://modmaven.dev"
23
+ }
30
24
}
31
25
32
26
base {
33
27
archivesName = mod_id
34
28
}
35
29
36
- // Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
37
30
java. toolchain. languageVersion = JavaLanguageVersion . of(21 )
38
31
39
- // minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
40
- // minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
41
-
42
- // Default run configurations.
43
- // These can be tweaked, removed, or duplicated as needed.
44
- runs {
45
- // applies to all the run configs below
46
- configureEach {
47
- // Recommended logging data for a userdev environment
48
- // The markers can be added/remove as needed separated by commas.
49
- // "SCAN": For mods scan.
50
- // "REGISTRIES": For firing of registry events.
51
- // "REGISTRYDUMP": For getting the contents of all registries.
52
- systemProperty ' forge.logging.markers' , ' REGISTRIES'
53
-
54
- // Recommended logging level for the console
55
- // You can set various levels here.
56
- // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
57
- systemProperty ' forge.logging.console.level' , ' debug'
58
-
59
- modSource project. sourceSets. main
60
- }
32
+ neoForge {
33
+ version = project. neo_version
61
34
62
- client {
63
- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
64
- systemProperty ' forge.enabledGameTestNamespaces ' , project. mod_id
35
+ parchment {
36
+ mappingsVersion = project . parchment_mappings_version
37
+ minecraftVersion = project. parchment_minecraft_version
65
38
}
66
39
67
- server {
68
- systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
69
- programArgument ' --nogui'
70
- }
40
+ runs {
41
+ client {
42
+ client()
43
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
44
+ }
71
45
72
- // This run config launches GameTestServer and runs all registered gametests, then exits.
73
- // By default, the server will crash when no gametests are provided.
74
- // The gametest system is also enabled by default for other run configs under the /test command.
75
- gameTestServer {
76
- systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
77
- }
46
+ server {
47
+ server()
48
+ programArgument ' --nogui'
49
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
50
+ }
78
51
79
- data {
80
- // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
81
- // workingDirectory project.file('run-data')
52
+ gameTestServer {
53
+ type = " gameTestServer"
54
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
55
+ }
82
56
83
- // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
84
- programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
57
+ data {
58
+ data()
59
+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
60
+ }
61
+
62
+ configureEach {
63
+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
64
+ logLevel = org.slf4j.event.Level . DEBUG
65
+ }
66
+ }
67
+
68
+ mods {
69
+ " ${ mod_id} " {
70
+ sourceSet(sourceSets. main)
71
+ }
85
72
}
86
73
}
87
74
88
- // Include resources generated by data generators.
89
75
sourceSets. main. resources { srcDir ' src/generated/resources' }
90
76
91
- // Sets up a dependency configuration called 'localRuntime'.
92
- // This configuration should be used instead of 'runtimeOnly' to declare
93
- // a dependency that will be present for runtime testing but that is
94
- // "optional", meaning it will not be pulled by dependents of this mod.
95
77
configurations {
96
78
runtimeClasspath. extendsFrom localRuntime
97
79
}
@@ -111,31 +93,28 @@ dependencies {
111
93
jarJar (" maven.modrinth:midnightlib:${ project.midnightlib_version} " )
112
94
}
113
95
114
- // This block of code expands all declared replace properties in the specified resource targets.
115
- // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
116
- // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
117
- // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
118
- tasks. withType(ProcessResources ). configureEach {
96
+ var generateModMetadata = tasks. register(" generateModMetadata" , ProcessResources ) {
119
97
var replaceProperties = [
120
- minecraft_version : minecraft_version,
121
- minecraft_version_range : minecraft_version_range,
122
- neo_version : neo_version,
123
- neo_version_range : neo_version_range,
124
- loader_version_range : loader_version_range,
125
- midnightlib_version : midnightlib_version,
126
- mod_id : mod_id,
127
- mod_name : mod_name,
128
- mod_license : mod_license,
129
- mod_version : mod_version,
130
- mod_authors : mod_authors,
131
- mod_description : mod_description
98
+ minecraft_version : minecraft_version,
99
+ minecraft_version_range : minecraft_version_range,
100
+ neo_version : neo_version,
101
+ neo_version_range : neo_version_range,
102
+ loader_version_range : loader_version_range,
103
+ midnightlib_version : midnightlib_version,
104
+ mod_id : mod_id,
105
+ mod_name : mod_name,
106
+ mod_license : mod_license,
107
+ mod_version : mod_version,
108
+ mod_authors : mod_authors,
109
+ mod_description : mod_description
132
110
]
133
111
inputs. properties replaceProperties
134
-
135
- filesMatching([' META-INF/neoforge.mods.toml' ]) {
136
- expand replaceProperties
137
- }
112
+ expand replaceProperties
113
+ from " src/main/templates"
114
+ into " build/generated/sources/modMetadata"
138
115
}
116
+ sourceSets. main. resources. srcDir generateModMetadata
117
+ neoForge. ideSyncTask generateModMetadata
139
118
140
119
// Example configuration to allow publishing using the maven-publish plugin
141
120
publishing {
@@ -152,10 +131,9 @@ publishing {
152
131
}
153
132
154
133
tasks. withType(JavaCompile ). configureEach {
155
- options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
134
+ options. encoding = ' UTF-8'
156
135
}
157
136
158
- // IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
159
137
idea {
160
138
module {
161
139
downloadSources = true
0 commit comments