forked from BynBang/OpenPrestige
Upload files to "/"
This commit is contained in:
1 parent
06269f1f65
commit
6d94493e58
4 files changed
+339
-220
No files matched your search
+233
-120
@@ -1,120 +1,233 @@
|
||||
plugins {
|
||||
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file('src/main/resources/prestige-client.accesswidener')
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
ideConfigGenerated(true)
|
||||
runDir 'run'
|
||||
programArg '--offlineDeveloperMode'
|
||||
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
|
||||
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
|
||||
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
|
||||
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
|
||||
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
|
||||
if (project.hasProperty('engineCmd')) vmArg "-Dprestige.engine.cmd=${project.property('engineCmd')}"
|
||||
if (project.hasProperty('engineReport')) vmArg "-Dprestige.engine.report=${project.property('engineReport')}"
|
||||
if (project.hasProperty('quickPlay')) { programArg '--quickPlaySingleplayer'; programArg project.property('quickPlay') }
|
||||
}
|
||||
}
|
||||
mods {
|
||||
"prestige" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
|
||||
shade
|
||||
implementation.extendsFrom shade
|
||||
engineMappings
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
|
||||
// natives-* the imgui-java64 libraries (extracted from the jar at runtime by imgui-java).
|
||||
// Linux natives are x86_64 only; the macOS dylib is universal (x86_64 + arm64).
|
||||
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
|
||||
// imgui-java-lwjgl3 pulls LWJGL 3.4.1 transitively, which replaces Minecraft's 3.3.3 jars and breaks world saving
|
||||
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
|
||||
shade "io.github.spair:imgui-java-natives-windows:${project.imgui_version}"
|
||||
shade "io.github.spair:imgui-java-natives-linux:${project.imgui_version}"
|
||||
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
|
||||
|
||||
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
|
||||
shade files('libs/classtransform-bundled.jar')
|
||||
// Yarn tiny shipped as prestige-engine/mappings.tiny for the production (Intermediary) runtime
|
||||
engineMappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
filteringCharset "UTF-8"
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 21
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
// Optional custom native builds take precedence over the upstream binaries.
|
||||
from('build/core-natives') {
|
||||
into 'prestige-natives'
|
||||
}
|
||||
from('build/arm-natives') {
|
||||
into 'prestige-natives'
|
||||
}
|
||||
// Unpack the shaded libs (imgui classes + native dll, ClassTransform) into the mod jar.
|
||||
from({
|
||||
configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}) {
|
||||
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
|
||||
exclude 'module-info.class', 'META-INF/versions/**'
|
||||
exclude 'imgui/extension/**'
|
||||
if (file('build/core-natives/windows-x86_64/imgui-java64.dll').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/imgui-java64.dll'
|
||||
}
|
||||
if (file('build/core-natives/linux-x86_64/libimgui-java64.so').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/libimgui-java64.so'
|
||||
}
|
||||
if (file('build/core-natives/macos-universal/libimgui-java64.dylib').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/libimgui-java64.dylib'
|
||||
}
|
||||
}
|
||||
from({ zipTree(configurations.engineMappings.singleFile) }) {
|
||||
include 'mappings/mappings.tiny'
|
||||
eachFile { it.relativePath = new RelativePath(true, 'prestige-engine', 'mappings.tiny') }
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
plugins {
|
||||
id 'net.fabricmc.fabric-loom-remap' version '1.17.21'
|
||||
}
|
||||
|
||||
version = "${project.mod_version}+${project.minecraft_version}"
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
def accessWidener = stonecutter.eval(stonecutter.current.version, '>=1.21.11')
|
||||
? 'prestige-client.accesswidener' : 'prestige-client-legacy.accesswidener'
|
||||
loom {
|
||||
accessWidenerPath = rootProject.file("src/main/resources/${accessWidener}")
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
ideConfigGenerated(true)
|
||||
runDir 'run'
|
||||
programArg '--offlineDeveloperMode'
|
||||
// dev command file / screenshot facility of the overlay: ./gradlew runClient -PuiCmd=<path>
|
||||
if (project.hasProperty('uiCmd')) vmArg "-Dprestige.ui.cmd=${project.property('uiCmd')}"
|
||||
// dev: -PdumpClasses=ap,C,c9 forces class init of instrumented classes (tools/java/ClinitDump.java, bridge/DumpHook)
|
||||
if (project.hasProperty('dumpClasses')) vmArg "-Dprestige.dump=${project.property('dumpClasses')}"
|
||||
// engine test driver (engine/EngineDev): ./gradlew runClient -PengineCmd=<command file> [-PengineReport=<seconds>] [-PquickPlay=<world>]
|
||||
if (project.hasProperty('engineCmd')) vmArg "-Dprestige.engine.cmd=${project.property('engineCmd')}"
|
||||
if (project.hasProperty('engineReport')) vmArg "-Dprestige.engine.report=${project.property('engineReport')}"
|
||||
if (project.hasProperty('quickPlay')) { programArg '--quickPlaySingleplayer'; programArg project.property('quickPlay') }
|
||||
}
|
||||
}
|
||||
mods {
|
||||
"prestige" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
// Libraries copied (unpacked) into the final mod jar so it is self-contained.
|
||||
shade
|
||||
implementation.extendsFrom shade
|
||||
engineMappings
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// Dear ImGui. The binding contains the Java classes, lwjgl3 the GL3/GLFW backend and
|
||||
// natives-* the imgui-java64 libraries (extracted from the jar at runtime by imgui-java).
|
||||
// Linux natives are x86_64 only; the macOS dylib is universal (x86_64 + arm64).
|
||||
shade "io.github.spair:imgui-java-binding:${project.imgui_version}"
|
||||
// imgui-java-lwjgl3 pulls LWJGL 3.4.1 transitively, which replaces Minecraft's 3.3.3 jars and breaks world saving
|
||||
shade("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}") { exclude group: 'org.lwjgl' }
|
||||
shade "io.github.spair:imgui-java-natives-windows:${project.imgui_version}"
|
||||
shade "io.github.spair:imgui-java-natives-linux:${project.imgui_version}"
|
||||
shade "io.github.spair:imgui-java-natives-macos:${project.imgui_version}"
|
||||
|
||||
// ClassTransform (net.lenni0451, customised build); engine/EnginePlugin uses it to apply the client's @CTransformer hooks.
|
||||
shade files(rootProject.file('libs/classtransform-bundled.jar'))
|
||||
// Yarn tiny shipped as prestige-engine/mappings.tiny for the production (Intermediary) runtime
|
||||
engineMappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
}
|
||||
|
||||
processResources {
|
||||
exclude { it.name.endsWith('.accesswidener') && it.name != accessWidener }
|
||||
inputs.property "version", project.version
|
||||
inputs.property "minecraft_version", project.minecraft_version
|
||||
filteringCharset "UTF-8"
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version, "minecraft_version": project.minecraft_version, "access_widener": accessWidener
|
||||
}
|
||||
filesMatching("prestige-engine/minecraft-version.txt") {
|
||||
expand "minecraft_version": project.minecraft_version
|
||||
}
|
||||
if (stonecutter.eval(stonecutter.current.version, '<1.21.11')) {
|
||||
doLast {
|
||||
def manifestFile = new File(destinationDir, 'prestige_ui/manifest_live.json')
|
||||
def manifest = new groovy.json.JsonSlurper().parse(manifestFile)
|
||||
def unavailable = manifest.modules.findAll { it['class'].contains('.module.spear.') }.collect { it.name }.toSet()
|
||||
manifest.modules.removeAll { unavailable.contains(it.name) }
|
||||
manifestFile.text = groovy.json.JsonOutput.toJson(manifest)
|
||||
['modules.tsv', 'settings.tsv'].each { name ->
|
||||
def table = new File(destinationDir, "prestige_ui/${name}")
|
||||
table.text = table.readLines('UTF-8').findAll { row ->
|
||||
!unavailable.contains(row.split('\t', -1)[name == 'modules.tsv' ? 1 : 0])
|
||||
}.join('\n') + '\n'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 21
|
||||
options.compilerArgs += ['-Xmaxerrs', '1000']
|
||||
}
|
||||
|
||||
// Each version's compiled transformer annotations own the target set. Generate
|
||||
// anchors from them so renamed/merged game classes cannot leave stale targets.
|
||||
def engineSources = layout.buildDirectory.dir('generated/engine/java')
|
||||
def engineResources = layout.buildDirectory.dir('generated/engine/resources')
|
||||
def generateEngineMetadata = tasks.register('generateEngineMetadata') {
|
||||
dependsOn tasks.named('compileJava')
|
||||
inputs.files(tasks.named('compileJava').flatMap { it.destinationDirectory })
|
||||
inputs.files(configurations.engineMappings)
|
||||
outputs.dirs(engineSources, engineResources)
|
||||
doLast {
|
||||
def namedToIntermediary = [:]
|
||||
new java.util.zip.ZipFile(configurations.engineMappings.singleFile).withCloseable { zip ->
|
||||
zip.getInputStream(zip.getEntry('mappings/mappings.tiny')).withReader('UTF-8') { reader ->
|
||||
reader.eachLine { line ->
|
||||
def fields = line.split('\t')
|
||||
if (fields[0] == 'c') namedToIntermediary[fields[2]] = fields[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
def targets = new TreeSet<String>()
|
||||
def transformers = new TreeSet<String>()
|
||||
fileTree(tasks.named('compileJava').get().destinationDirectory).matching {
|
||||
include 'dev/zprestige/prestige/mixin/*.class'
|
||||
}.each { file ->
|
||||
def node = new org.objectweb.asm.tree.ClassNode()
|
||||
new org.objectweb.asm.ClassReader(file.bytes).accept(node, org.objectweb.asm.ClassReader.SKIP_CODE)
|
||||
def annotation = (node.visibleAnnotations ?: []).find { it.desc == 'Lnet/lenni0451/classtransform/annotations/CTransformer;' }
|
||||
if (annotation == null) annotation = (node.invisibleAnnotations ?: []).find { it.desc == 'Lnet/lenni0451/classtransform/annotations/CTransformer;' }
|
||||
if (annotation != null) {
|
||||
transformers.add(node.name.replace('/', '.'))
|
||||
def values = annotation.values
|
||||
for (int i = 0; i < values.size(); i += 2) {
|
||||
if (values[i] == 'value') values[i + 1].each { targets.add(it.internalName) }
|
||||
if (values[i] == 'name') values[i + 1].each { targets.add(it.replace('.', '/')) }
|
||||
}
|
||||
}
|
||||
}
|
||||
def sourceRoot = engineSources.get().asFile
|
||||
def sources = new File(sourceRoot, 'dev/zprestige/prestige/engine/mixin')
|
||||
def resources = new File(engineResources.get().asFile, 'prestige-engine')
|
||||
assert sourceRoot.canonicalPath.startsWith(layout.buildDirectory.get().asFile.canonicalPath + File.separator)
|
||||
delete sourceRoot
|
||||
sources.mkdirs()
|
||||
resources.mkdirs()
|
||||
def named = targets.toList()
|
||||
def intermediary = named.collect { target ->
|
||||
if (!namedToIntermediary.containsKey(target)) throw new GradleException("No intermediary mapping for ${target}")
|
||||
namedToIntermediary[target]
|
||||
}
|
||||
['N': named, 'I': intermediary].each { prefix, names ->
|
||||
names.eachWithIndex { target, index ->
|
||||
def name = String.format('%s%02d', prefix, index)
|
||||
new File(sources, "${name}.java").text = """package dev.zprestige.prestige.engine.mixin;
|
||||
@org.spongepowered.asm.mixin.Mixin(targets = "${target.replace('/', '.')}", remap = false, priority = 2000)
|
||||
public abstract class ${name} {}
|
||||
"""
|
||||
}
|
||||
}
|
||||
new File(resources, 'targets.named.list').text = named.collect { it.replace('/', '.') }.join('\n') + '\n'
|
||||
new File(resources, 'targets.intermediary.list').text = intermediary.collect { it.replace('/', '.') }.join('\n') + '\n'
|
||||
new File(resources, 'transformers.list').text = transformers.join('\n') + '\n'
|
||||
}
|
||||
}
|
||||
def compileEngineAnchors = tasks.register('compileEngineAnchors', JavaCompile) {
|
||||
dependsOn generateEngineMetadata
|
||||
source engineSources
|
||||
classpath = sourceSets.main.compileClasspath
|
||||
destinationDirectory = layout.buildDirectory.dir('classes/engine')
|
||||
}
|
||||
sourceSets.main.output.dir(engineResources, builtBy: generateEngineMetadata)
|
||||
sourceSets.main.output.dir(compileEngineAnchors.flatMap { it.destinationDirectory }, builtBy: compileEngineAnchors)
|
||||
processResources {
|
||||
exclude 'prestige-engine/targets.named.list', 'prestige-engine/targets.intermediary.list', 'prestige-engine/transformers.list'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar') {
|
||||
dependsOn generateEngineMetadata
|
||||
from engineSources
|
||||
}
|
||||
|
||||
// Applied scripts do not inherit plugin implementation classes; pass ASM operations
|
||||
// from Loom's existing classpath instead of adding another dependency.
|
||||
ext.hookAsm = [
|
||||
node: { new org.objectweb.asm.tree.ClassNode() },
|
||||
reader: { data -> new org.objectweb.asm.ClassReader(data) },
|
||||
arguments: { descriptor -> org.objectweb.asm.Type.getArgumentTypes(descriptor).toList() },
|
||||
methodInstruction: { instruction -> instruction instanceof org.objectweb.asm.tree.MethodInsnNode }
|
||||
]
|
||||
apply from: rootProject.file('gradle/hook-check.gradle')
|
||||
|
||||
jar {
|
||||
// Optional custom native builds take precedence over the upstream binaries.
|
||||
from(rootProject.file('build/core-natives')) {
|
||||
into 'prestige-natives'
|
||||
}
|
||||
from(rootProject.file('build/arm-natives')) {
|
||||
into 'prestige-natives'
|
||||
}
|
||||
// Unpack the shaded libs (imgui classes + native dll, ClassTransform) into the mod jar.
|
||||
from({
|
||||
configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}) {
|
||||
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
|
||||
exclude 'module-info.class', 'META-INF/versions/**'
|
||||
exclude 'imgui/extension/**'
|
||||
if (rootProject.file('build/core-natives/windows-x86_64/imgui-java64.dll').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/imgui-java64.dll'
|
||||
}
|
||||
if (rootProject.file('build/core-natives/linux-x86_64/libimgui-java64.so').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/libimgui-java64.so'
|
||||
}
|
||||
if (rootProject.file('build/core-natives/macos-universal/libimgui-java64.dylib').isFile()) {
|
||||
exclude 'io/imgui/java/native-bin/libimgui-java64.dylib'
|
||||
}
|
||||
}
|
||||
from({ zipTree(configurations.engineMappings.singleFile) }) {
|
||||
include 'mappings/mappings.tiny'
|
||||
eachFile { it.relativePath = new RelativePath(true, 'prestige-engine', 'mappings.tiny') }
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
Reference in new issue
Block a user