// 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 // Pas de outputs déclarés : vérifie chaque jar à chaque run (skip si présent). 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://cdn.modrinth.com/data/P7dR8mSH/versions/bq3SsNGk/fabric-api-0.163.0%2B26.3.jar', new File(outDir, 'fabric-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', 'downloadMcLibs') group = 'fabric' description = 'Lance le client Minecraft avec le mod (dev visuel).' doFirst { layout.buildDirectory.dir('runClient/game/mods').get().asFile.mkdirs() copy { from(tasks.named('jar')) into(layout.buildDirectory.dir('runClient/game/mods')) } // fabric-api en dur dans mods/ : découverte fichier garantie (classpath ignoré par Knot). copy { from(new File(layout.buildDirectory.dir('mc').get().asFile, 'fabric-api.jar')) into(layout.buildDirectory.dir('runClient/game/mods')) } } // NixOS : dlopen ne voit ni libGL ni libvulkan sans LD_LIBRARY_PATH (cf launcher). def nixStore = new File('/nix/store') def glDirs = [] ['/run/opengl-driver/lib', '/run/current-system/sw/lib'].each { d -> if (new File(d).exists()) glDirs << d } if (nixStore.exists()) { nixStore.eachDir { e -> def n = e.name if (n.contains('libglvnd') || n.contains('vulkan-loader') || n.contains('alsa-lib') || n.contains('pulseaudio') || (n.contains('pipewire') && !n.contains('python'))) { def lib = new File(e, 'lib') if (lib.exists()) glDirs << lib.absolutePath } } } def prevLd = System.getenv('LD_LIBRARY_PATH') environment('LD_LIBRARY_PATH', (prevLd ? prevLd + ':' : '') + glDirs.join(':')) if (!System.getenv('SDL_VIDEODRIVER') && (System.getenv('WAYLAND_DISPLAY') || new File('/run/user/1000/wayland-1').exists())) { environment('SDL_VIDEODRIVER', 'wayland') } 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)}") }, new File(layout.buildDirectory.dir('mc').get().asFile, 'fabric-api.jar'), 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' }