Skip to content

Commit 84e7bf3

Browse files
committed
26.1 buildscript
1 parent 63a026e commit 84e7bf3

4 files changed

Lines changed: 70 additions & 39 deletions

File tree

build.gradle.kts

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1819
import dev.dediamondpro.buildsource.Platform
1920
import dev.dediamondpro.buildsource.VersionDefinition
2021
import dev.dediamondpro.buildsource.VersionRange
22+
import net.fabricmc.loom.task.RemapJarTask
2123

2224
plugins {
2325
alias(libs.plugins.kotlin)
@@ -68,7 +70,8 @@ val shade: Configuration by configurations.creating {
6870
}
6971

7072
val shadeModImplementation: Configuration by configurations.creating {
71-
configurations.modImplementation.get().extendsFrom(this)
73+
val parent = if (mcPlatform.isObfuscated) "modImplementation" else "implementation"
74+
configurations.getByName(parent).extendsFrom(this)
7275
}
7376

7477
// Version definitions
@@ -144,22 +147,19 @@ val kotlinForForgeVersion = VersionDefinition(
144147
"1.21.5" to "5.7.0",
145148
"1.21.8" to "5.9.0",
146149
)
147-
val universalMcVersion = VersionDefinition(
150+
val universalVersion = VersionDefinition(
148151
"1.21.1" to "1.21",
149152
"1.21.8" to "1.21.7",
150153
"1.21.10" to "1.21.9",
151154
default = mcPlatform.versionString
152-
)
153-
val universalVersion = VersionDefinition(
154-
default = "${universalMcVersion.get(mcPlatform)}-${mcPlatform.loaderString}:466"
155-
)
155+
).let { VersionDefinition(default = "${it.get(mcPlatform)}-${mcPlatform.loaderString}:466") }
156156

157157
dependencies {
158158
minecraft("com.mojang:minecraft:${mcVersion.get(mcPlatform)}")
159159

160-
if (mcPlatform.major == 1) {
160+
if (mcPlatform.isObfuscated) {
161161
@Suppress("UnstableApiUsage")
162-
mappings(loom.layered {
162+
add("mappings", loom.layered {
163163
officialMojangMappings()
164164
parchmentVersion.getOrNull(mcPlatform)?.let {
165165
parchment("org.parchmentmc.data:parchment-$it@zip")
@@ -168,18 +168,16 @@ dependencies {
168168
}
169169

170170
if (mcPlatform.isFabric) {
171-
modImplementation("net.fabricmc:fabric-loader:0.17.3")
172-
173-
modImplementation("net.fabricmc:fabric-language-kotlin:${libs.versions.fabric.language.kotlin.get()}")
174-
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion.get(mcPlatform)}")
175-
modImplementation("com.terraformersmc:modmenu:${modMenuVersion.get(mcPlatform)}")
171+
val modImpl = if (mcPlatform.isObfuscated) "modImplementation" else "implementation"
172+
add(modImpl, "net.fabricmc:fabric-loader:0.17.3")
173+
add(modImpl, "net.fabricmc:fabric-language-kotlin:${libs.versions.fabric.language.kotlin.get()}")
174+
add(modImpl, "net.fabricmc.fabric-api:fabric-api:${fabricApiVersion.get(mcPlatform)}")
175+
add(modImpl, "com.terraformersmc:modmenu:${modMenuVersion.get(mcPlatform)}")
176176
} else if (mcPlatform.isNeoForge) {
177177
"neoForge"("net.neoforged:neoforge:${neoForgeVersion.get(mcPlatform)}")
178-
179178
implementation("thedarkcolour:kotlinforforge-neoforge:${kotlinForForgeVersion.get(mcPlatform)}")
180179
} else if (mcPlatform.isForge) {
181180
"forge"("net.minecraftforge:forge:${forgeVersion.get(mcPlatform)}")
182-
183181
implementation("thedarkcolour:kotlinforforge:${kotlinForForgeVersion.get(mcPlatform)}")
184182
}
185183

@@ -197,22 +195,19 @@ dependencies {
197195
}
198196
}
199197

200-
val accesWidener = if (mcPlatform.version >= 1_21_09) {
201-
"1.21.9.resourcify"
202-
} else if (mcPlatform.minor == 21) {
203-
"1.21.resourcify"
204-
} else {
205-
"1.20.resourcify"
198+
val accessWidener = when {
199+
mcPlatform.version >= 26_00_00 -> "26.1.resourcify"
200+
mcPlatform.version >= 1_21_09 -> "1.21.9.resourcify"
201+
mcPlatform.minor == 21 -> "1.21.resourcify"
202+
else -> "1.20.resourcify"
206203
}
207-
208-
val mixinPath = if (mcPlatform.version >= 1_21_11) {
209-
"mixins.resourcify-1.21.11.json"
210-
} else {
211-
"mixins.resourcify.json"
204+
val mixinPath = when {
205+
mcPlatform.version >= 1_21_11 -> "mixins.resourcify-1.21.11.json"
206+
else -> "mixins.resourcify.json"
212207
}
213208

214209
loom {
215-
accessWidenerPath = rootProject.file("src/main/resources/$accesWidener.accesswidener")
210+
accessWidenerPath = rootProject.file("src/main/resources/$accessWidener.accesswidener")
216211

217212
if (mcPlatform.isForge) forge {
218213
convertAccessWideners.set(true)
@@ -232,9 +227,19 @@ base.archivesName.set(
232227
}-${mcPlatform.loaderString})-$mod_version"
233228
)
234229

230+
val outputJar = if (mcPlatform.isObfuscated) {
231+
tasks.named<RemapJarTask>("remapJar").flatMap { it.archiveFile }
232+
} else {
233+
tasks.named<ShadowJar>("shadowJar").flatMap { it.archiveFile }
234+
}
235+
235236
publishMods {
236-
file.set(tasks.remapJar.get().archiveFile)
237-
displayName.set("[${compatibleMcVersion.get(mcPlatform).getName()}-${mcPlatform.loaderString}] $mod_name $mod_version")
237+
file.set(outputJar)
238+
displayName.set(
239+
"[${
240+
compatibleMcVersion.get(mcPlatform).getName()
241+
}-${mcPlatform.loaderString}] $mod_name $mod_version"
242+
)
238243
version.set(mod_version)
239244
changelog.set(rootProject.file("changelog.md").readText())
240245
type.set(STABLE)
@@ -276,8 +281,8 @@ publishMods {
276281
}
277282

278283
tasks {
279-
named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
280-
archiveClassifier.set("dev")
284+
named<ShadowJar>("shadowJar") {
285+
archiveClassifier.set(if (mcPlatform.isObfuscated) "dev" else "")
281286
configurations = listOf(shade, shadeModImplementation)
282287
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
283288

@@ -288,16 +293,20 @@ tasks {
288293
relocate("org.commonmark", "dev.dediamondpro.resourcify.libs.commonmark")
289294
relocate("org.ccil.cowan.tagsoup", "dev.dediamondpro.resourcify.libs.tagsoup")
290295
}
291-
remapJar {
292-
input.set(shadowJar.get().archiveFile)
293-
finalizedBy("copyJar")
294-
if (mcPlatform.isNeoForge) {
295-
atAccessWideners.add("$accesWidener.accesswidener")
296+
if (mcPlatform.isObfuscated) {
297+
named<RemapJarTask>("remapJar") {
298+
input.set(named<ShadowJar>("shadowJar").flatMap { it.archiveFile })
299+
finalizedBy("copyJar")
300+
if (mcPlatform.isNeoForge) {
301+
atAccessWideners.add("$accessWidener.accesswidener")
302+
}
296303
}
304+
} else {
305+
named("shadowJar") { finalizedBy("copyJar") }
297306
}
298307
register<Copy>("copyJar") {
299308
File("${project.rootDir}/jars").mkdir()
300-
from(remapJar.get().archiveFile)
309+
from(outputJar)
301310
into("${project.rootDir}/jars")
302311
}
303312
clean { delete("${project.rootDir}/jars") }
@@ -306,7 +315,7 @@ tasks {
306315
"id" to mod_id,
307316
"name" to mod_name,
308317
"version" to mod_version,
309-
"aw" to accesWidener,
318+
"aw" to accessWidener,
310319
"mixinPath" to mixinPath,
311320
"mcVersion" to compatibleMcVersion.get(mcPlatform).getLoaderRange(mcPlatform),
312321
"minNeoForgeVersion" to minimumNeoForgeVersion.get(mcPlatform)

buildSrc/src/main/java/dev/dediamondpro/buildsource/Platform.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public boolean isForgeLike() {
8383
return loader.isForgeLike();
8484
}
8585

86+
public boolean isObfuscated() {
87+
return major == 1;
88+
}
89+
8690
public String getName() {
8791
return getVersionString() + "-" + loader.toString().toLowerCase();
8892
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ val platforms = listOf(
4747
"1.21.8-fabric",
4848
"1.21.10-fabric",
4949
"1.21.11-fabric",
50-
// "26.1-fabric",
50+
"26.1-fabric",
5151
)
5252

5353
stonecutter {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
accessWidener v2 official
2+
3+
# Access to pack from entry
4+
accessible class net/minecraft/client/gui/screens/packs/PackSelectionModel$EntryBase
5+
accessible field net/minecraft/client/gui/screens/packs/PackSelectionModel$EntryBase pack Lnet/minecraft/server/packs/repository/Pack;
6+
7+
# Access to file from pack
8+
accessible field net/minecraft/server/packs/repository/Pack resources Lnet/minecraft/server/packs/repository/Pack$ResourcesSupplier;
9+
accessible field net/minecraft/server/packs/FilePackResources$FileResourcesSupplier content Ljava/io/File;
10+
accessible method net/minecraft/client/gui/screens/packs/PackSelectionModel$EntryBase getSelfList ()Ljava/util/List;
11+
accessible method net/minecraft/client/gui/screens/packs/PackSelectionModel$EntryBase getOtherList ()Ljava/util/List;
12+
accessible field net/minecraft/client/gui/screens/packs/PackSelectionModel onListChanged Ljava/util/function/Consumer;
13+
14+
# Access message in GenericMessageScreen, used for world downloading screen
15+
accessible field net/minecraft/client/gui/screens/GenericMessageScreen textWidget Lnet/minecraft/client/gui/components/FocusableTextWidget;
16+
17+
# Access to rendering buffer
18+
accessible field net/minecraft/client/renderer/GameRenderer renderBuffers Lnet/minecraft/client/renderer/RenderBuffers;

0 commit comments

Comments
 (0)