Skip to content

Commit 530b1bd

Browse files
committed
Initial work on updating UnityTranslate again
1 parent d7453d8 commit 530b1bd

File tree

6 files changed

+134
-146
lines changed

6 files changed

+134
-146
lines changed

build.gradle.kts

Lines changed: 69 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import com.modrinth.minotaur.dependencies.DependencyType
22
import com.modrinth.minotaur.dependencies.ModDependency
33
import dev.deftu.gradle.tools.minecraft.CurseRelation
44
import dev.deftu.gradle.tools.minecraft.CurseRelationType
5-
import dev.deftu.gradle.utils.MinecraftInfo
6-
import dev.deftu.gradle.utils.MinecraftVersion
75
import dev.deftu.gradle.utils.ModLoader
86
import dev.deftu.gradle.utils.includeOrShade
9-
import org.jetbrains.kotlin.daemon.common.toHexString
10-
import java.net.URI
11-
import java.security.MessageDigest
7+
import dev.deftu.gradle.utils.version.MinecraftVersions
128

139
plugins {
1410
java
@@ -37,10 +33,6 @@ toolkitLoomHelper {
3733
useTweaker("org.spongepowered.asm.launch.MixinTweaker")
3834
useForgeMixin("unitytranslate.mixins.json", true)
3935
}
40-
41-
if (mcData.isForgeLike) {
42-
useKotlinForForge()
43-
}
4436
}
4537

4638
version = "${project.property("mod.version")}+mc${mcData.version}-${mcData.loader.friendlyString}"
@@ -68,21 +60,45 @@ repositories {
6860
maven("https://repo.plo.su")
6961
maven("https://repo.plasmoverse.com/releases")
7062
maven("https://repo.plasmoverse.com/snapshots")
63+
maven("https://repo.nyon.dev/releases")
64+
maven("https://mvn.devos.one/releases")
65+
maven("https://mvn.devos.one/snapshots")
66+
}
67+
68+
val leastCommonMcVersion = when (mcData.version) {
69+
MinecraftVersions.VERSION_1_21_10 -> "1.21.9"
70+
MinecraftVersions.VERSION_1_21_8 -> "1.21.6"
71+
MinecraftVersions.VERSION_1_21_4 -> "1.21.3"
72+
MinecraftVersions.VERSION_1_21_1 -> "1.21"
73+
else -> mcData.version.toString()
74+
}
75+
76+
val architecturyVersion = when (mcData.version) {
77+
MinecraftVersions.VERSION_1_20_1 -> "9.2.14"
78+
MinecraftVersions.VERSION_1_20_4 -> "11.1.17"
79+
MinecraftVersions.VERSION_1_20_6 -> "12.1.4"
80+
MinecraftVersions.VERSION_1_21_1 -> "13.0.6"
81+
MinecraftVersions.VERSION_1_21_4 -> "15.0.3"
82+
MinecraftVersions.VERSION_1_21_5 -> "16.1.4"
83+
MinecraftVersions.VERSION_1_21_8 -> "17.0.8"
84+
MinecraftVersions.VERSION_1_21_10 -> "18.0.6"
85+
86+
else -> throw IllegalStateException()
7187
}
7288

73-
val architecturyVersion = when (mcData.version.rawVersion) {
74-
1_20_01 -> "9.2.14"
75-
1_20_04 -> "11.1.17"
76-
1_20_06 -> "12.1.4"
77-
1_21_01 -> "13.0.6"
89+
val klfVersion = when (mcData.version) {
90+
MinecraftVersions.VERSION_1_20_1, MinecraftVersions.VERSION_1_20_4 -> "2.0"
91+
MinecraftVersions.VERSION_1_21_1, MinecraftVersions.VERSION_1_21_4, MinecraftVersions.VERSION_1_21_5, MinecraftVersions.VERSION_1_21_8 -> "3.0"
92+
MinecraftVersions.VERSION_1_21_10 -> "3.1"
7893

7994
else -> throw IllegalStateException()
8095
}
8196

82-
val lwjglVersion = when (mcData.version.rawVersion) {
83-
1_20_01 -> "3.3.1"
84-
1_20_04 -> "3.3.2"
85-
1_20_06, 1_21_01 -> "3.3.3"
97+
val fabricPermissionsApiVersion = when (mcData.version) {
98+
MinecraftVersions.VERSION_1_20_1 -> "0.3.1"
99+
MinecraftVersions.VERSION_1_21_1, MinecraftVersions.VERSION_1_21_4, MinecraftVersions.VERSION_1_21_5 -> "0.3.3"
100+
MinecraftVersions.VERSION_1_21_8 -> "0.4.1"
101+
MinecraftVersions.VERSION_1_21_10 -> "0.5.0"
86102

87103
else -> throw IllegalStateException()
88104
}
@@ -95,11 +111,13 @@ dependencies {
95111
modApi("dev.architectury:architectury-${mcData.loader.friendlyString}:$architecturyVersion")
96112

97113
if (mcData.isFabric) {
98-
val modMenuVersion = when (mcData.version.rawVersion) {
99-
1_20_01 -> "7.2.2"
100-
1_20_04 -> "9.2.0"
101-
1_20_06 -> "10.0.0"
102-
1_21_01 -> "11.0.2"
114+
val modMenuVersion = when (mcData.version) {
115+
MinecraftVersions.VERSION_1_20_1 -> "7.2.2"
116+
MinecraftVersions.VERSION_1_21_1 -> "11.0.2"
117+
MinecraftVersions.VERSION_1_21_4 -> "13.0.3"
118+
MinecraftVersions.VERSION_1_21_5 -> "14.0.0"
119+
MinecraftVersions.VERSION_1_21_8 -> "15.0.0"
120+
MinecraftVersions.VERSION_1_21_10 -> "16.0.0-rc.1"
103121

104122
else -> throw IllegalStateException()
105123
}
@@ -108,44 +126,41 @@ dependencies {
108126
}
109127

110128
if (mcData.isFabric) {
111-
includeOrShade(modImplementation("me.lucko:fabric-permissions-api:0.3.1")!!)
129+
includeOrShade(modImplementation("me.lucko:fabric-permissions-api:$fabricPermissionsApiVersion")!!)
112130
}
113131

114132
val useSVC = true
115133

116134
if (useSVC)
117-
modRuntimeOnly("maven.modrinth:simple-voice-chat:${mcData.loader.friendlyString}-${if (mcData.version != MinecraftVersion.VERSION_1_21_1) mcData.version else "1.21"}-${project.property("voicechat_version")}")
135+
modRuntimeOnly("maven.modrinth:simple-voice-chat:${mcData.loader.friendlyString}-${mcData.version}-${project.property("voicechat_version")}")
118136
else if (!mcData.isNeoForge) {
119-
modRuntimeOnly("maven.modrinth:plasmo-voice:${mcData.loader.friendlyString}-${if (mcData.version != MinecraftVersion.VERSION_1_21_1) mcData.version else "1.21"}-${project.property("plasmo_version")}")
137+
modRuntimeOnly("maven.modrinth:plasmo-voice:${mcData.loader.friendlyString}-${leastCommonMcVersion}-${project.property("plasmo_version")}")
120138
runtimeOnly("su.plo.voice.api:server:${project.property("plasmo_api_version")}")
121139
runtimeOnly("su.plo.voice.api:client:${project.property("plasmo_api_version")}")
122140
}
123141

124-
val clothConfigVersion = when(mcData.version.rawVersion) {
125-
1_20_01 -> "11.1.118"
126-
1_20_04 -> "13.0.121"
127-
1_20_06 -> "14.0.126"
128-
1_21_01 -> "15.0.128"
142+
val clothConfigVersion = when(mcData.version) {
143+
MinecraftVersions.VERSION_1_20_1 -> "11.1.118"
144+
MinecraftVersions.VERSION_1_21_1 -> "15.0.128"
145+
MinecraftVersions.VERSION_1_21_4 -> "17.0.144"
146+
MinecraftVersions.VERSION_1_21_5 -> "18.0.145"
147+
MinecraftVersions.VERSION_1_21_8 -> "19.0.147"
148+
MinecraftVersions.VERSION_1_21_10 -> "20.0.149"
129149

130150
else -> throw IllegalStateException()
131151
}
132152

133-
modCompileOnly("maven.modrinth:cloth-config:${clothConfigVersion}+${mcData.loader.friendlyString}")
134-
135-
val cerbonsApiVersion = if (mcData.isForgeLike) "XWZQbKsr" else "1.1.0"
136-
modCompileOnly("maven.modrinth:cerbons-api:$cerbonsApiVersion")
137-
138-
val talkBalloonsVersion = if (mcData.isForgeLike) "kN8kdQ22" else "1.0.0"
139-
modCompileOnly("maven.modrinth:talk-balloons:$talkBalloonsVersion")
153+
modImplementation("maven.modrinth:cloth-config:${clothConfigVersion}+${mcData.loader.friendlyString}")
154+
modImplementation("maven.modrinth:talk-balloons:${project.property("talk_balloons_version")}+${if (mcData.version == MinecraftVersions.VERSION_1_21_1) "1.21.1" else leastCommonMcVersion}-${mcData.loader.friendlyString}")
140155

141156
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:${project.property("kotlin_serialization_version")}")
142157
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:${project.property("kotlin_serialization_version")}")
143158

144-
implementation("org.jetbrains.kotlin:kotlin-reflect:${project.property("kotlin_version")}")
145-
146159
if (mcData.isFabric) {
147160
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
148161
modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}")
162+
} else {
163+
modImplementation("dev.nyon:KotlinLangForge:${property("kotlinlangforge_version")}-k${property("kotlin_version")}-${klfVersion}+${mcData.loader.friendlyString}")
149164
}
150165

151166
val jws = includeOrShade("org.java-websocket:Java-WebSocket:1.5.7")!!
@@ -163,7 +178,12 @@ dependencies {
163178
minecraftRuntimeLibraries(okhttp!!)
164179
}
165180

166-
shade(implementation("org.lwjgl:lwjgl:$lwjglVersion")!!)
181+
// UnityTranslateLib
182+
shade(implementation("xyz.bluspring.unitytranslate:UnityTranslateLib:${rootProject.property("unitytranslatelib_version")}")!!)
183+
shade(implementation("xyz.bluspring.unitytranslate:UnityTranslateLib-natives-windows-amd64:${rootProject.property("unitytranslatelib_version")}")!!)
184+
shade(implementation("xyz.bluspring.unitytranslate:UnityTranslateLib-natives-linux-amd64:${rootProject.property("unitytranslatelib_version")}")!!)
185+
186+
includeOrShade(api("com.github.jnr:jnr-ffi:${rootProject.property("jnr_version")}")!!)
167187
}
168188

169189
toolkitReleases {
@@ -176,13 +196,14 @@ toolkitReleases {
176196
if (mcData.loader == ModLoader.FABRIC) {
177197
dependencies.add(ModDependency("Ha28R6CL", DependencyType.REQUIRED)) // Fabric Language Kotlin
178198
} else if (mcData.isForgeLike) {
179-
dependencies.add(ModDependency("ordsPcFz", DependencyType.REQUIRED)) // Kotlin for Forge
199+
dependencies.add(ModDependency("1vrSzlao", DependencyType.REQUIRED)) // KotlinLangForge (it's so much better oh my GOD)
180200
}
181201

182202
dependencies.addAll(listOf(
183203
ModDependency("lhGA9TYQ", DependencyType.REQUIRED), // Architectury API
184204
ModDependency("l3tS9WUS", DependencyType.OPTIONAL), // Talk Balloons
185205
ModDependency("9eGKb6K1", DependencyType.OPTIONAL), // Simple Voice Chat
206+
ModDependency("1bZhdhsH", DependencyType.OPTIONAL), // Plasmo Voice
186207
))
187208
}
188209

@@ -192,60 +213,22 @@ toolkitReleases {
192213
if (mcData.loader == ModLoader.FABRIC) {
193214
relations.add(CurseRelation("fabric-language-kotlin", CurseRelationType.REQUIRED)) // Fabric Language Kotlin
194215
} else if (mcData.isForgeLike) {
195-
relations.add(CurseRelation("kotlin-for-forge", CurseRelationType.REQUIRED)) // Kotlin for Forge
216+
relations.add(CurseRelation("kotlinlangforge", CurseRelationType.REQUIRED)) // KotlinLangForge
196217
}
197218

198219
relations.addAll(listOf(
199220
CurseRelation("architectury-api", CurseRelationType.REQUIRED), // Architectury API
200221
CurseRelation("talk-balloons", CurseRelationType.OPTIONAL), // Talk Balloons
201222
CurseRelation("simple-voice-chat", CurseRelationType.OPTIONAL), // Simple Voice Chat
223+
CurseRelation("plasmo-voice", CurseRelationType.OPTIONAL), // Plasmo Voice
202224
))
203225
}
204226

205227
changelogFile.set(File(project.rootDir, "CHANGELOG.md"))
206228
}
207229

208230
tasks {
209-
create("getLwjgl") {
210-
doFirst {
211-
val dir = layout.buildDirectory.dir("lwjgl/lwjgl").get().asFile
212-
if (!dir.exists())
213-
dir.mkdirs()
214-
215-
for (suffix in listOf("", "-natives-windows", "-natives-macos", "-natives-linux")) {
216-
val lwjglFile = File(dir, "lwjgl-$lwjglVersion$suffix.jar")
217-
if (lwjglFile.exists()) {
218-
logger.info("LWJGL file ${lwjglFile.name} already downloaded, not redownloading it.")
219-
continue
220-
}
221-
222-
val hash = URI("https://repo1.maven.org/maven2/org/lwjgl/lwjgl/$lwjglVersion/lwjgl-$lwjglVersion$suffix.jar.sha256").toURL().readText()
223-
val downloadUrl = URI("https://repo1.maven.org/maven2/org/lwjgl/lwjgl/$lwjglVersion/lwjgl-$lwjglVersion$suffix.jar").toURL()
224-
225-
logger.info("Downloading ${lwjglFile.name}...")
226-
lwjglFile.createNewFile()
227-
lwjglFile.writeBytes(downloadUrl.readBytes())
228-
229-
val sha1 = MessageDigest.getInstance("SHA256")
230-
sha1.update(lwjglFile.readBytes())
231-
232-
if (hash != sha1.digest().toHexString()) {
233-
lwjglFile.delete()
234-
throw SecurityException("SHA1 mismatch for ${lwjglFile.name} (expected $hash, got ${sha1.digest().toHexString()})")
235-
}
236-
}
237-
238-
val versionFile = File(dir, "version.txt")
239-
240-
if (!versionFile.exists())
241-
versionFile.createNewFile()
242-
243-
versionFile.writeText(lwjglVersion, Charsets.UTF_8)
244-
}
245-
}
246-
247231
processResources {
248-
dependsOn("getLwjgl")
249232
val properties = mutableMapOf<String, String>()
250233

251234
properties.putAll(mapOf(
@@ -267,26 +250,20 @@ tasks {
267250
return@run null
268251
}
269252

270-
val version = MinecraftInfo.ForgeLike.getKotlinForForgeVersion(mcData.version)
271-
val majorVersion = version.split(".")[0]
272-
"[$majorVersion,)"
253+
"[${klfVersion.split(".")[0]},)"
273254
}
274255

275256
if (mcData.isForgeLike) {
276-
properties["forge_kotlin_version"] = mcData.dependencies.forgeLike.kotlinForForgeVersion
257+
properties["forge_kotlin_version"] = klfVersion
277258
properties["forge_loader_version"] = forgeLoaderVersion!!
278259
properties["mod_loader_name"] = mcData.loader.friendlyString
279260

280-
if (mcData.isForge && mcData.version.rawVersion <= 1_20_01) {
281-
properties["forge_loader"] = "javafml"
282-
} else {
283-
properties["forge_loader"] = "kotlinforforge"
284-
}
261+
properties["forge_loader"] = "klf"
285262

286263
if (mcData.isForge) {
287264
properties["FUCKING_REQUIRED"] = "mandatory=true"
288265
} else {
289-
properties["FUCKING_REQUIRED"] = "required=true"
266+
properties["FUCKING_REQUIRED"] = "type=\"required\""
290267
}
291268
}
292269

@@ -315,22 +292,9 @@ tasks {
315292
}
316293
}
317294

318-
// Modified from https://github.com/DexPatcher/dexpatcher-tool/blob/v1.2.1/tool/build.gradle#L57-L79
319-
val shadowBugWorkaround = create<Jar>("shadowBugWorkaround") {
320-
dependsOn("getLwjgl")
321-
destinationDirectory.set(layout.buildDirectory.dir("shadow-bug-workaround"))
322-
archiveBaseName.set("nested-content")
323-
324-
from(layout.buildDirectory.dir("lwjgl"))
325-
}
326-
327295
fatJar {
328-
dependsOn("shadowBugWorkaround")
329-
330296
relocate("okhttp3", "xyz.bluspring.unitytranslate.shaded.okhttp3")
331297
relocate("okio", "xyz.bluspring.unitytranslate.shaded.okio")
332298
exclude("kotlin/**/*", "org/**/*")
333-
334-
from(shadowBugWorkaround)
335299
}
336300
}

gradle.properties

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ org.gradle.daemon=false
1111

1212
# Loom Setup
1313
dgt.loom.mappings=mojmap
14-
dgt.loom.mappings.flavor=parchment
14+
#dgt.loom.mappings.flavor=parchment
1515

1616
# Mod Properties
1717
mod.version = 0.2.0-beta
@@ -23,19 +23,31 @@ dgt.loom.mappings.flavor=parchment
2323

2424
### Common
2525
# https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api
26-
voicechat_api_version=2.5.0
26+
voicechat_api_version=2.6.0
2727
# https://github.com/plasmoapp/plasmo-voice/releases
28-
plasmo_api_version=2.0.3
28+
plasmo_api_version=2.1.6
2929

3030
# https://modrinth.com/mod/simple-voice-chat/versions?g=1.20.1
31-
voicechat_version=2.5.16
31+
voicechat_version=2.6.6
3232

3333
# https://modrinth.com/plugin/plasmo-voice/versions?g=1.20.1
34-
plasmo_version=2.0.10
34+
plasmo_version=2.1.6
3535

36-
kotlin_version=2.0.20
37-
kotlin_coroutines_version=1.8.1
38-
kotlin_serialization_version=1.7.2
36+
kotlin_version=2.2.21
37+
kotlin_coroutines_version=1.10.2
38+
kotlin_serialization_version=1.9.0
3939

4040
# https://central.sonatype.com/artifact/com.squareup.okhttp3/okhttp/4.12.0/versions
41-
okhttp_version=4.12.0
41+
okhttp_version=5.3.1
42+
43+
# http://mvn.devos.one/#/snapshots/xyz/bluspring/unitytranslate/UnityTranslateLib
44+
unitytranslatelib_version = 0.4.2
45+
46+
# https://central.sonatype.com/artifact/com.github.jnr/jnr-ffi?smo=true
47+
jnr_version = 2.2.17
48+
49+
# https://modrinth.com/mod/kotlin-lang-forge
50+
kotlinlangforge_version = 2.10.6
51+
52+
# https://modrinth.com/mod/talk-balloons
53+
talk_balloons_version = 1.3.1

0 commit comments

Comments
 (0)