157 lines
7.5 KiB
Groovy
157 lines
7.5 KiB
Groovy
// SurviePote - nosingleplayer : build SANS loom.
|
|
// MC 26.3 n'est plus obfusqué (noms Mojang lisibles dans le jar vanilla) et Mojang ne
|
|
// publie plus de mappings (pas de client_mappings/server_mappings, pas de Yarn 26.x).
|
|
// On compile directement contre le jar client Mojang + loader/mixin en compileOnly.
|
|
plugins {
|
|
id 'java'
|
|
}
|
|
|
|
version = project.mod_version
|
|
group = project.maven_group
|
|
|
|
base {
|
|
archivesName = project.archives_base_name
|
|
}
|
|
|
|
def mcDir = layout.buildDirectory.dir('mc')
|
|
|
|
tasks.register('downloadMcLibs') {
|
|
def manifestUrl = 'https://piston-meta.mojang.com/mc/game/version_manifest_v2.json'
|
|
def mcVersion = project.minecraft_version
|
|
def loaderVersion = project.loader_version
|
|
outputs.dir(mcDir)
|
|
doLast {
|
|
def outDir = mcDir.get().asFile
|
|
outDir.mkdirs()
|
|
def dl = { String url, File dest ->
|
|
if (!dest.exists()) {
|
|
println "Téléchargement ${dest.name} ..."
|
|
new URL(url).withInputStream { i -> dest.withOutputStream { it << i } }
|
|
}
|
|
}
|
|
def manifest = new groovy.json.JsonSlurper().parse(new URL(manifestUrl))
|
|
def entry = manifest.versions.find { it.id == mcVersion }
|
|
if (entry == null) throw new GradleException("Version MC introuvable : ${mcVersion}")
|
|
def versionJson = new groovy.json.JsonSlurper().parse(new URL(entry.url))
|
|
dl(versionJson.downloads.client.url, new File(outDir, 'client.jar'))
|
|
dl("https://maven.fabricmc.net/net/fabricmc/fabric-loader/${loaderVersion}/fabric-loader-${loaderVersion}.jar",
|
|
new File(outDir, 'fabric-loader.jar'))
|
|
dl('https://maven.fabricmc.net/net/fabricmc/sponge-mixin/0.17.5+mixin.0.8.7/sponge-mixin-0.17.5+mixin.0.8.7.jar',
|
|
new File(outDir, 'sponge-mixin.jar'))
|
|
dl('https://repo1.maven.org/maven2/org/slf4j/slf4j-api/2.0.17/slf4j-api-2.0.17.jar',
|
|
new File(outDir, 'slf4j-api.jar'))
|
|
dl('https://libraries.minecraft.net/com/mojang/brigadier/1.3.11/brigadier-1.3.11.jar',
|
|
new File(outDir, 'brigadier.jar'))
|
|
// Dependances transitives du jar client requises pour compiler contre les classes Mojang
|
|
// (verifie au javac : sans elles, "class file for Keyable/Nullable not found").
|
|
dl('https://libraries.minecraft.net/com/mojang/datafixerupper/10.0.21/datafixerupper-10.0.21.jar',
|
|
new File(outDir, 'datafixerupper.jar'))
|
|
dl('https://libraries.minecraft.net/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.jar',
|
|
new File(outDir, 'jspecify.jar'))
|
|
// Requis pour lire les class files Mojang au javac (sinon "Cannot attach type
|
|
// annotations @Nullable" + "class file for Object2LongMap not found").
|
|
dl('https://libraries.minecraft.net/it/unimi/dsi/fastutil/8.5.18/fastutil-8.5.18.jar',
|
|
new File(outDir, 'fastutil-8.5.18.jar'))
|
|
dl('https://libraries.minecraft.net/com/google/guava/guava/33.6.0-jre/guava-33.6.0-jre.jar',
|
|
new File(outDir, 'guava-33.6.0-jre.jar'))
|
|
dl('https://libraries.minecraft.net/com/google/guava/failureaccess/1.0.3/failureaccess-1.0.3.jar',
|
|
new File(outDir, 'failureaccess-1.0.3.jar'))
|
|
dl('https://libraries.minecraft.net/com/google/code/gson/gson/2.14.0/gson-2.14.0.jar',
|
|
new File(outDir, 'gson-2.14.0.jar'))
|
|
dl('https://libraries.minecraft.net/org/apache/commons/commons-lang3/3.20.0/commons-lang3-3.20.0.jar',
|
|
new File(outDir, 'commons-lang3-3.20.0.jar'))
|
|
dl('https://repo1.maven.org/maven2/it/unimi/dsi/fastutil/8.5.18/fastutil-8.5.18.jar',
|
|
new File(outDir, 'fastutil.jar'))
|
|
// fabric-api est un bundle de modules imbriqués (META-INF/jars) : on l'éclate pour le classpath.
|
|
def fapiBundle = new File(outDir, 'fabric-api-bundle.jar')
|
|
dl('https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/0.163.0+26.3/fabric-api-0.163.0+26.3.jar',
|
|
fapiBundle)
|
|
copy {
|
|
from { zipTree(fapiBundle) }
|
|
include 'META-INF/jars/*.jar'
|
|
into outDir
|
|
eachFile { it.path = it.name }
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compileOnly files({ tasks.named('downloadMcLibs').map { mcDir.get().asFile.listFiles().findAll { it.name.endsWith('.jar') } } })
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
it.options.release = 25
|
|
it.dependsOn('downloadMcLibs')
|
|
}
|
|
|
|
processResources {
|
|
inputs.property 'version', project.version
|
|
filesMatching('fabric.mod.json') {
|
|
expand 'version': project.version
|
|
}
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
}
|
|
|
|
// Dev : lance le vrai client MC 26.3 + pala (sans loom).
|
|
// Requiert un premier lancement SurviePote/Prism (common/ rempli : versions, libraries, assets).
|
|
// Usage : ./gradlew runClient (monde solo offline dispo pour vérifier visuels).
|
|
def survieCommon = new File(System.getProperty('user.home'), '.surviepote/common')
|
|
|
|
tasks.register('extractClientNatives', Copy) {
|
|
dependsOn('downloadMcLibs')
|
|
def mcVersion = project.minecraft_version
|
|
def versionJson = new groovy.json.JsonSlurper().parse(
|
|
new File(survieCommon, "versions/${mcVersion}/${mcVersion}.json"))
|
|
from(versionJson.libraries.findAll { lib ->
|
|
lib.name.contains(':natives-linux') && (lib.rules == null || lib.rules.any { it.action == 'allow' && (it.os == null || it.os.name == 'linux') })
|
|
}.collect { lib ->
|
|
def art = lib.downloads.artifact
|
|
zipTree(new File(survieCommon, "libraries/${art.path}"))
|
|
})
|
|
into(layout.buildDirectory.dir('runClient/natives'))
|
|
include('**/*.so')
|
|
eachFile { f -> f.path = f.name }
|
|
}
|
|
|
|
tasks.register('runClient', JavaExec) {
|
|
dependsOn('extractClientNatives', 'jar')
|
|
group = 'fabric'
|
|
description = 'Lance le client Minecraft avec le mod (dev visuel).'
|
|
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }
|
|
def mcVersion = project.minecraft_version
|
|
def versionJson = new groovy.json.JsonSlurper().parse(
|
|
new File(survieCommon, "versions/${mcVersion}/${mcVersion}.json"))
|
|
def loaderVersion = project.loader_version
|
|
def fabricJson = new groovy.json.JsonSlurper().parse(
|
|
new File(survieCommon, "versions/${mcVersion}-fabric-${loaderVersion}/${mcVersion}-fabric-${loaderVersion}.json"))
|
|
def mavenToPath = { String coord ->
|
|
def parts = coord.split(':')
|
|
return "${parts[0].replace('.', '/')}/${parts[1]}/${parts[2]}/${parts[1]}-${parts[2]}.jar"
|
|
}
|
|
classpath = files(
|
|
new File(survieCommon, "versions/${mcVersion}/${mcVersion}.jar"),
|
|
versionJson.libraries.findAll { lib ->
|
|
!(lib.name.contains(':natives-')) && (lib.rules == null || lib.rules.any { it.action == 'allow' && (it.os == null || it.os.name == 'linux') })
|
|
}.collect { new File(survieCommon, "libraries/${it.downloads.artifact.path}") },
|
|
fabricJson.libraries.collect { new File(survieCommon, "libraries/${mavenToPath(it.name)}") },
|
|
sourceSets.main.output
|
|
)
|
|
mainClass = 'net.fabricmc.loader.impl.launch.knot.KnotClient'
|
|
args = [
|
|
'--gameDir', layout.buildDirectory.dir('runClient/game').get().asFile.absolutePath,
|
|
'--assetsDir', new File(survieCommon, 'assets').absolutePath,
|
|
'--assetIndex', '34',
|
|
'--version', 'pala-dev',
|
|
'--username', 'Dev', '--uuid', '00000000-0000-0000-0000-000000000000',
|
|
'--accessToken', '0', '--versionType', 'release'
|
|
]
|
|
jvmArgs = [
|
|
"-Djava.library.path=${layout.buildDirectory.dir('runClient/natives').get().asFile.absolutePath}",
|
|
'-Xmx4G'
|
|
]
|
|
systemProperties['org.lwjgl.util.Debug'] = 'false'
|
|
}
|