1
- import groovy.json.JsonSlurper
2
1
plugins {
3
- id ' fabric-loom' version ' 1.1-SNAPSHOT'
4
- id ' maven-publish'
2
+ id ' fabric-loom' version ' 1.8-SNAPSHOT'
5
3
id " de.undercouch.download" version " 4.1.2"
6
4
}
7
5
8
- sourceCompatibility = JavaVersion . VERSION_16
9
- targetCompatibility = JavaVersion . VERSION_16
6
+ sourceCompatibility = JavaVersion . VERSION_17
7
+ targetCompatibility = JavaVersion . VERSION_17
10
8
11
9
version = project. mod_version
12
10
group = project. maven_group
13
11
14
- def default_minecraft_version = " 1.19.2"
15
- def minecraft_version = project. properties. containsKey(" buildVersion" ) ? project. getProperties(). get(" buildVersion" ) : default_minecraft_version
16
- def minecraft_major_version = minecraft_version. split(" \\ ." )[0 ] as int // Always return 1, unless mojang goes haywire :P
17
- def minecraft_main_version = minecraft_version. split(" \\ ." )[1 ] as int
18
- def mc_requirement = " ${ minecraft_major_version} .${ minecraft_main_version} .x"
19
- def minecraft_minor_version = minecraft_version. split(" \\ ." ). size() > 2 ? minecraft_version. split(" \\ ." )[2 ] as int : 0
20
- def minecraft_version_str = (minecraft_major_version as String ) + (minecraft_main_version as String ). padLeft(2 , ' 0' ) + (minecraft_minor_version as String ). padLeft(2 , ' 0' )
21
- def yarn_mappings = new JsonSlurper (). parse((" https://meta.fabricmc.net/v2/versions/yarn/" + minecraft_version). toURL())[0 ][" version" ]
22
- def loader_version = project. loader_version
23
- def fapi_version = getModrinthVersion(" fabric" , minecraft_version, " fabric-api" )
24
-
25
- version = minecraft_version + " -" + project. mod_version
12
+ version = project. mod_version + " +" + project. minecraft_version
26
13
27
14
repositories {
28
15
// Add repositories to retrieve artifacts from in here.
@@ -51,72 +38,34 @@ task setupLibrary() {
51
38
}
52
39
}
53
40
54
- task downloadOptimizedMod () {
55
- doLast {
56
- def outputPath = " run/mods/"
57
-
58
- download {
59
- src getModrinthDLURL(" fabric" , minecraft_version, " lazydfu" )
60
- dest outputPath + " dfu.jar"
61
- overwrite true
62
- }
63
- download {
64
- src getModrinthDLURL(" fabric" , minecraft_version, " ferrite-core" )
65
- dest outputPath + " ferrite-core.jar"
66
- overwrite true
67
- }
68
- download {
69
- src getModrinthDLURL(" fabric" , minecraft_version, " smoothboot-fabric" )
70
- dest outputPath + " smooth-boot.jar"
71
- overwrite true
72
- }
73
- download {
74
- src getModrinthDLURL(" fabric" , minecraft_version, " ksyxis" )
75
- dest outputPath + " ksyxis.jar"
76
- overwrite true
77
- }
78
- }
79
- }
80
-
81
41
dependencies {
82
- // To change the versions see the gradle.properties file
83
- annotationProcessor " systems.manifold:manifold-preprocessor:${ project.manifold_version} "
84
- minecraft " com.mojang:minecraft:${ minecraft_version} "
85
- mappings " net.fabricmc:yarn:${ yarn_mappings} :v2"
86
- modImplementation " net.fabricmc:fabric-loader:${ loader_version} "
42
+ minecraft " com.mojang:minecraft:${ project.minecraft_version} "
43
+ mappings loom. officialMojangMappings()
44
+ modImplementation " net.fabricmc:fabric-loader:${ project.loader_version} "
87
45
88
- // Fabric API. This is technically optional, but you probably want it anyway.
89
- modImplementation " net.fabricmc.fabric-api:fabric-api:${ fapi_version} "
46
+ modImplementation " net.fabricmc.fabric-api:fabric-api:${ project.fabric_version} "
90
47
modImplementation files(" lib/mtr-fabric.jar" )
91
-
92
- // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
93
- // You may need to force-disable transitiveness on them.
94
48
}
95
49
96
50
processResources {
97
51
inputs. property " version" , project. version
98
52
99
53
filesMatching(" fabric.mod.json" ) {
100
54
expand (
101
- " version" : project. version,
102
- " mc_version" : mc_requirement
55
+ " version" : project. version,
56
+ " mc_version" : " >= ${ project.minecraft_version } "
103
57
)
104
58
}
105
59
}
106
60
107
61
tasks. withType(JavaCompile ). configureEach {
108
- // ensure that the encoding is set to UTF-8, no matter what the system default is
109
- // this fixes some edge cases with special characters not displaying correctly
110
- // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
111
- // If Javadoc is generated, this must be specified in that task too.
112
62
it. options. encoding = " UTF-8"
113
63
114
- // Minecraft 1.17 (21w19a) upwards uses Java 16 .
115
- def targetVersion = 16
64
+ // Minecraft 1.19 upwards uses Java 17 .
65
+ def targetVersion = 17
116
66
if (JavaVersion . current(). isJava9Compatible()) {
117
67
it. options. release = targetVersion
118
68
}
119
- options. compilerArgs + = [' -Xplugin:Manifold' , ' -AMC_VERSION=' + minecraft_version_str]
120
69
}
121
70
122
71
java {
@@ -130,58 +79,4 @@ jar {
130
79
from(" LICENSE" ) {
131
80
rename { " ${ it} _${ project.archivesBaseName} " }
132
81
}
133
- }
134
-
135
- // configure the maven publication
136
- publishing {
137
- publications {
138
- mavenJava(MavenPublication ) {
139
- // add all the jars that should be included when publishing to maven
140
- artifact(remapJar) {
141
- builtBy remapJar
142
- }
143
- artifact(sourcesJar) {
144
- builtBy remapSourcesJar
145
- }
146
- }
147
- }
148
-
149
- // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
150
- allprojects {
151
- repositories {
152
- maven {
153
- url = " https://minecraft.guntram.de/maven/"
154
- }
155
- maven { url ' https://www.jitpack.io' }
156
- maven { url ' https://oss.sonatype.org/content/repositories/snapshots' }
157
- }
158
-
159
- afterEvaluate {
160
- for (def task in it. tasks) {
161
- if (! project. file(" lib/mtr-fabric.jar" ). exists()) {
162
- task. dependsOn rootProject. tasks. setupLibrary
163
- }
164
- }
165
- }
166
- }
167
- }
168
-
169
- static def getModrinthVersion (loader , minecraftVersion , projectId ) {
170
- def versionsArray = new JsonSlurper (). parse((" https://api.modrinth.com/v2/project/" + projectId + " /version" ). toURL())
171
- for (def versionElement : versionsArray) {
172
- if (versionElement[" loaders" ]. contains(loader) && versionElement[" version_type" ] == " release" && versionElement[" game_versions" ]. contains(minecraftVersion)) {
173
- return versionElement[" version_number" ]
174
- }
175
- }
176
- return " "
177
- }
178
-
179
- static def getModrinthDLURL (loader , minecraftVersion , projectId ) {
180
- def versionsArray = new JsonSlurper (). parse((" https://api.modrinth.com/v2/project/" + projectId + " /version" ). toURL())
181
- for (def versionElement : versionsArray) {
182
- if (versionElement[" loaders" ]. contains(loader) && versionElement[" game_versions" ]. contains(minecraftVersion)) {
183
- return versionElement[" files" ][0 ][" url" ]. toURL()
184
- }
185
- }
186
- return " "
187
82
}
0 commit comments