Skip to content

Commit

Permalink
loader: re-enable support for modlauncher platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Jun 18, 2024
1 parent 5163d93 commit 45c0d40
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "gg.essential"
version = "0.6.0"
version = "0.6.0+loader"

java.withSourcesJar()

Expand Down
71 changes: 45 additions & 26 deletions src/main/kotlin/gg/essential/essential-loader.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,51 @@ when {

//FIXME: Fix loader not working on ml
platform.isModLauncher -> {
error("Modlauncher is currently not supported")
// dependencies {
// val relocatedPackage = findProperty("essential.loader.package")?.toString() ?: throw GradleException("""
// A package for the Essential loader to be relocated to has not been set.
// You need to set `essential.loader.package` in the project's `gradle.properties` file to a package where Essential's loader will be relocated to.
// For example: `essential.loader.package = org.example.coolmod.relocated.essential`
// """.trimIndent())
// val relocationAttribute =
// registerRelocationAttribute("essential-loader-relocated") {
// relocate("gg.essential.loader.stage0", "$relocatedPackage.stage0")
// // preserve stage1 path
// rename("gg/essential/loader/stage0/stage1.jar", "gg/essential/loader/stage0/stage1.jar")
// }
// essentialLoader.attributes {
// attribute(relocationAttribute, true)
// }
// if (platform.mcVersion < 11700) {
// "forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher8:1.2.2")!!)
// } else {
// "forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher9:1.2.2")!!)
// }
// }
// tasks.named<Jar>("jar") {
// dependsOn(essentialLoader)
// from({ zipTree(essentialLoader.singleFile) })
// }
val relocatedPackage = findProperty("essential.loader.package")?.toString() ?: throw GradleException("""
A package for the Essential loader to be relocated to has not been set.
You need to set `essential.loader.package` in the project's `gradle.properties` file to a package where Essential's loader will be relocated to.
For example: `essential.loader.package = org.example.coolmod.relocated.essential`
""".trimIndent())
dependencies {
val relocationAttribute =
registerRelocationAttribute("essential-loader-relocated") {
relocate("gg.essential.loader.stage0", "$relocatedPackage.stage0")
// preserve stage1 path
rename("gg/essential/loader/stage0/stage1.jar", "gg/essential/loader/stage0/stage1.jar")
}
essentialLoader.attributes {
attribute(relocationAttribute, true)
}
if (platform.mcVersion < 11700) {
"forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher8:1.2.2")!!)
} else {
"forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher9:1.2.2")!!)
}
}
tasks {
named<Jar>("jar") {
dependsOn(essentialLoader)
from({ zipTree(essentialLoader.singleFile) })
}
register("generateEssentialLoaderMixinConfig") {
val outputFile = file("${layout.buildDirectory}/generated-resources/mixin.stage0.essential-loader.json")
outputs.file(outputFile)
doLast {
outputFile.writeText("""
{
"minVersion": "0.8",
"compatibilityLevel": "JAVA_16",
"plugin": "$relocatedPackage.stage0.EssentialStage0MixinPlugin",
"package" : "$relocatedPackage.stage0"
}
""".trimIndent())
}
}
named<ProcessResources>("processResources") {
dependsOn(named("generateEssentialLoaderMixinConfig"))
from(file("${layout.buildDirectory}/generated-resources"))
}
}
}

else -> error("No loader available for this platform")
Expand Down

0 comments on commit 45c0d40

Please sign in to comment.