Archive incari-client (client, 26.3, clean)

This commit is contained in:
2026-11-28 00:54:38 -06:00
parent 7a6174687f
commit 12838e838c
2383 changed files with 280266 additions and 0 deletions
+254
View File
@@ -0,0 +1,254 @@
import java.util.Properties
import net.ltgt.gradle.errorprone.errorprone
plugins {
`java-library`
}
// The game: the patched vendor tree in work/client (generated by `./incari setup`, never
// tracked) compiled together with the Incari code in src/main/java that vendor patches call.
// They are one compilation because the dependency runs both ways: patches call Incari hooks,
// and the hooks use game types.
val repoRoot = rootProject.layout.projectDirectory
val minecraftVersion: String = Properties().run {
repoRoot.file("incari.properties").asFile.reader().use { load(it) }
getProperty("minecraft.version")
}
val vendorSources = repoRoot.dir("work/client/src/main/java")
val vendorClasspathList = repoRoot.file("work/cache/versions/$minecraftVersion/classpath.txt")
/** Mojang's libraries for this version, as `incari fetch` downloaded and checked them. */
val vendorLibraries = run {
// A local, not the script property: a lambda capturing the script can't be cached.
val root = repoRoot.asFile
providers.fileContents(vendorClasspathList).asText.map { text ->
text.lines().filter { it.isNotBlank() }.map { root.resolve(it.trim()) }
}.orElse(emptyList())
}
val clientJar = repoRoot.file("work/cache/versions/$minecraftVersion/client.jar")
// The game's own resources (textures, models, data packs, version.json) from Mojang's jar, next
// to the classes compiled from source. Kept in build/, which is never tracked or published.
val gameResources = tasks.register<Sync>("gameResources") {
description = "Extracts the non-class files of Mojang's client jar."
from(zipTree(clientJar)) {
exclude("**/*.class")
// Mojang's signature covers Mojang's classes, not these; a partial signature breaks loading.
exclude("META-INF/**")
}
into(layout.buildDirectory.dir("game-resources"))
}
/**
* Vendor files that patches/classes.txt deletes or replaces. Replacements are Incari sources in
* this module's src/main/java (`./incari apply` also copies them into work/client, so the tree
* is complete on its own); the build compiles them from here and skips the vendor path.
*/
val manifestOwnedFiles: Set<String> = repoRoot.file("patches/classes.txt").asFile.readLines()
.map { it.substringBefore('#').trim() }
.filter { it.isNotEmpty() }
.map { it.split(Regex("\\s+"))[1].replace('.', '/') + ".java" }
.toSet()
// The online service's URL (ADR 0058), built in: `-Pincari.online.url=<wss://...>`, else
// incari.properties' `incari.online.url`; empty turns accounts off. A URL, never a key or secret:
// anything in a page can be read by whoever opens it. The page's ?online= and the desktop's
// -Dincari.online.url override it for testing against a local service.
val onlineUrl: String = providers.gradleProperty("incari.online.url").orNull ?: Properties().run {
repoRoot.file("incari.properties").asFile.reader().use { load(it) }
getProperty("incari.online.url", "")
}
val onlineUrlSource = tasks.register("onlineUrlSource") {
description = "Writes the online service's URL into a generated source."
val url = onlineUrl
val out = layout.buildDirectory.dir("generated/sources/online")
inputs.property("url", url)
outputs.dir(out)
doLast {
val file = out.get().file("incari/client/online/OnlineUrl.java").asFile
file.parentFile.mkdirs()
val quoted = url.replace("\\", "\\\\").replace("\"", "\\\"")
file.writeText(
"""
|package incari.client.online;
|
|/** Generated by :client's onlineUrlSource from incari.online.url. */
|final class OnlineUrl {
| static final String BUILT_IN = "$quoted";
|
| private OnlineUrl() {}
|}
|""".trimMargin())
}
}
// This build's Incari version, public repository and game version (incari.properties), and whether it's a release
// build (`-Pteavm.release`, as `./incari build` makes): only those show the title screen's update
// notice. Dev builds never do, except for tests (-Dincari.updates=on, the page's ?updates=on).
val incariProperties = Properties().apply {
repoRoot.file("incari.properties").asFile.reader().use { load(it) }
}
val buildInfoSource = tasks.register("buildInfoSource") {
description = "Writes this build's Incari version, repository, featured servers, game version and release flag into a generated source."
val version = incariProperties.getProperty("incari.version", "")
val minecraftVersion = incariProperties.getProperty("minecraft.version", "")
val repository = incariProperties.getProperty("incari.repository", "")
val featured = incariProperties.getProperty("incari.featured", "")
val release = providers.gradleProperty("teavm.release").isPresent
val out = layout.buildDirectory.dir("generated/sources/build-info")
inputs.property("version", version)
inputs.property("repository", repository)
inputs.property("featured", featured)
inputs.property("minecraftVersion", minecraftVersion)
inputs.property("release", release)
outputs.dir(out)
doLast {
val file = out.get().file("incari/client/IncariBuild.java").asFile
file.parentFile.mkdirs()
fun quoted(text: String) = "\"" + text.replace("\\", "\\\\").replace("\"", "\\\"") + "\""
file.writeText(
"""
|package incari.client;
|
|/** Generated by :client's buildInfoSource from incari.properties and -Pteavm.release. */
|public final class IncariBuild {
| /** This build's Incari Client version. */
| public static final String VERSION = ${quoted(version)};
| /** The public repository, where the update notice leads. */
| public static final String REPOSITORY = ${quoted(repository)};
| /** The featured servers built in, as "name|address" joined by ";" (ADR 0062). */
| public static final String FEATURED = ${quoted(featured)};
| /**
| * The Minecraft release this tree targets ("26.3"). For code that runs before the game's
| * own SharedConstants can be read, such as the page naming its cached client jar.
| */
| public static final String MINECRAFT_VERSION = ${quoted(minecraftVersion)};
| /** Whether this is a release build, the kind players are given. */
| public static final boolean RELEASE = $release;
|
| private IncariBuild() {}
|}
|""".trimMargin())
}
}
sourceSets.main {
java.srcDir(onlineUrlSource)
java.srcDir(buildInfoSource)
java.srcDir(vendorSources)
// Locals, not script properties: a lambda capturing the script can't be cached.
val vendorRoot = vendorSources.asFile
val ownedByManifest = manifestOwnedFiles
java.exclude { element -> element.file.startsWith(vendorRoot) && element.relativePath.pathString in ownedByManifest }
output.dir(mapOf("builtBy" to gameResources), layout.buildDirectory.dir("game-resources"))
}
dependencies {
api(project(":platform-api"))
api(project(":net"))
api(project(":via"))
// Incari's terrain mesher: the game's section compiles go to it through incari.client.render.mesher.
api(project(":mesher"))
// The module framework (ADR 0046): incari.client.modules adapts the game to it, and lists
// the features below.
api(project(":framework"))
// Incari accounts and the online service (ADR 0058): incari.client.online draws the account
// screens and feeds it the world.
api(project(":online"))
implementation(project(":features:togglesprint"))
implementation(project(":features:lowfire"))
implementation(project(":features:nohurtcam"))
implementation(project(":features:clearchat"))
implementation(project(":features:armorpotionview"))
implementation(project(":features:customscoreboard"))
implementation(project(":features:waypoints"))
implementation(project(":features:minimap"))
implementation(project(":features:fpsdisplay"))
implementation(project(":features:cps"))
implementation(project(":features:reachdisplay"))
implementation(project(":features:keystrokes"))
implementation(project(":features:coordinates"))
implementation(project(":features:shieldtotem"))
implementation(project(":features:cooldownindicator"))
implementation(project(":features:crosshair"))
implementation(project(":features:freelook"))
implementation(project(":features:zoom"))
implementation(project(":features:saturation"))
implementation(project(":features:weatherchanger"))
implementation(project(":features:lowshield"))
implementation(project(":features:shortitems"))
implementation(project(":features:oldtextures"))
implementation(project(":features:blockoutline"))
implementation(project(":features:hitcolor"))
implementation(project(":features:glintcolor"))
implementation(project(":features:hiteffects"))
implementation(project(":features:fullbright"))
implementation(project(":features:customsky"))
implementation(project(":features:hitboxes"))
implementation(project(":features:schematics"))
implementation(project(":features:norender"))
implementation(project(":features:fastcrystal"))
implementation(project(":features:oldanimations"))
implementation(project(":features:shulkertooltips"))
implementation(project(":features:theme"))
api(files(vendorLibraries))
// Annotations Mojang compiled against but doesn't ship in the game's libraries.
compileOnlyApi(libs.jetbrains.annotations)
compileOnlyApi(libs.jsr305)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj)
testImplementation(libs.archunit)
testImplementation(testFixtures(project(":online")))
testRuntimeOnly(libs.junit.launcher)
}
tasks.compileJava {
val tree = vendorSources.asFile
val classpathList = vendorClasspathList.asFile
doFirst {
if (!tree.isDirectory || !classpathList.isFile) {
throw GradleException("The client tree isn't set up yet. Run: ./incari setup")
}
}
// Roughly 9,000 vendor files in one compilation.
options.isFork = true
options.forkOptions.memoryMaximumSize = "6g"
// Vendor code is compiled as-is and never edited to silence a warning, so this compilation
// allows warnings. Incari's sources get the strict treatment in strictCompile below.
options.compilerArgs.add("-Xlint:none")
options.errorprone {
// Error Prone and NullAway check Incari's code here, never Mojang's.
excludedPaths = ".*/work/client/.*"
}
}
// Recompiles only Incari's sources in this module, against the full build, with the flags every
// other Incari module uses: -Xlint:all -Werror plus Error Prone and NullAway. The output is
// thrown away; this is a check, and `check` runs it.
val strictCompile = tasks.register<JavaCompile>("strictCompile") {
group = "verification"
description = "Compiles Incari's own sources in :client with warnings as errors."
source = fileTree("src/main/java")
classpath = files(tasks.compileJava.flatMap { it.destinationDirectory }) + sourceSets.main.get().compileClasspath
destinationDirectory = layout.buildDirectory.dir("strict-compile")
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(25) }
options.compilerArgs.addAll(listOf("-Xlint:all,-classfile", "-Werror"))
}
tasks.check {
dependsOn(strictCompile)
}
tasks.test {
// Game classes loaded by tests write logs/ into the working directory; keep that in build/.
val runDir = layout.buildDirectory.dir("test-run").get().asFile
workingDir = runDir
systemProperty("incari.repoRoot", rootDir.path)
// ArchUnit imports the whole game to check the replacement classes.
maxHeapSize = "3g"
doFirst { runDir.mkdirs() }
}