Started work on fixing the common mixin

This commit is contained in:
coolGi
2023-04-26 22:28:28 +09:30
parent d708867c74
commit fc3653e577
6 changed files with 102 additions and 66 deletions
+90 -59
View File
@@ -269,6 +269,77 @@ subprojects { p ->
jar.dependsOn(shadowJar)
// Put stuff from gradle.properties into the mod info
processResources {
def resourceTargets = [ // Location of where to inject the properties
// Properties for each of the loaders
"fabric.mod.json",
"quilt.mod.json",
"META-INF/mods.toml",
// The mixins for each of the loaders
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
]
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
// Fix forge version numbering system as it is weird
// For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"] which make more sense
def compatible_forgemc_versions = "${compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)")
// println compatible_forgemc_versions
// Quilt's custom contributors system
// This has to be like
// "Person": "Developer", "Another person": "Developer"
def quilt_contributors = []
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
for (dev in mod_author_list) {
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
}
quilt_contributors.reverse()
// println quilt_contributors.join(", ")
// TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated
// println p.tasks.findByName('shadowJar')
def replaceProperties = [
version : mod_version,
mod_name : mod_readable_name,
group : maven_group,
authors : mod_authors,
description : mod_description,
homepage : mod_homepage,
source : mod_source,
issues : mod_issues,
discord : mod_discord,
minecraft_version : minecraft_version,
compatible_minecraft_versions: compatible_minecraft_versions,
compatible_forgemc_versions : compatible_forgemc_versions,
java_version : java_version,
quilt_contributors : "{"+quilt_contributors.join(", ")+"}"
]
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
inputs.properties replaceProperties
replaceProperties.put "project", project
filesMatching(resourceTargets) {
expand replaceProperties
}
intoTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
include resourceTargets
expand replaceProperties
}
into target
}
}
}
}
// Adds the standalone jar's entrypoint
jar {
from "LICENSE.txt"
@@ -422,68 +493,17 @@ allprojects { p ->
}
// Put stuff from gradle.properties into the mod info
processResources {
def resourceTargets = ["fabric.mod.json", "quilt.mod.json", "META-INF/mods.toml"] // Location of where to inject the properties
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
// Fix forge version numbering system as it is weird
// For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"] which make more sense
def compatible_forgemc_versions = "${compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)")
// println compatible_forgemc_versions
// Quilt's custom contributors system
// This has to be like
// "Person": "Developer", "Another person": "Developer"
def quilt_contributors = []
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
for (dev in mod_author_list) {
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
}
quilt_contributors.reverse()
// println quilt_contributors.join(", ")
def replaceProperties = [
version : mod_version,
mod_name : mod_readable_name,
group : maven_group,
authors : mod_authors,
description : mod_description,
homepage : mod_homepage,
source : mod_source,
issues : mod_issues,
discord : mod_discord,
minecraft_version : minecraft_version,
compatible_minecraft_versions: compatible_minecraft_versions,
compatible_forgemc_versions : compatible_forgemc_versions,
java_version : java_version,
quilt_contributors : "{"+quilt_contributors.join(", ")+"}"
]
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
inputs.properties replaceProperties
replaceProperties.put "project", project
filesMatching(resourceTargets) {
expand replaceProperties
}
intoTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
include resourceTargets
expand replaceProperties
}
into target
}
}
}
}
task copyAccessWidener(type: Copy) {
task copyCommonLoaderResources(type: Copy) {
from project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener")
into(file(p.file("build/resources/main")))
rename "${accessWidenerVersion}.lod.accesswidener", "lod.accesswidener"
// Move the fabricLike mixin to its different places for each subproject
if (findProject(":fabricLike")) {
from project(":fabricLike").file("src/main/resources/DistantHorizons.fabricLike.mixins.json")
into(file(p.file("build/resources/main")))
rename "DistantHorizons.fabricLike.mixins.json", "DistantHorizons." + p.name + ".fabricLike.mixins.json"
}
}
task copyCoreResources(type: Copy) {
@@ -491,6 +511,17 @@ allprojects { p ->
into p.file("build/resources/main")
}
// TODO: This method doesnt seem to actually remove it from the jar, probably called at incorrect spots
task deleteDuplicatedCommonLoaderResources(type: Delete) {
// Delete the duplicated fabricLike.mixins.json
delete p.file("build/resources/main/DistantHorizons.fabricLike.mixins.json")
// Delete all the duplicated accesswideners
delete fileTree(p.file("build/resources/main")) {
include "*.lod.accesswidener"
}
}
tasks.withType(JavaCompile) {
if (isMinecraftSubProject) {
options.release = rootProject.java_version as Integer
+4 -2
View File
@@ -115,12 +115,14 @@ task deleteResources(type: Delete) {
processResources {
dependsOn(copyCoreResources)
dependsOn(copyAccessWidener)
dependsOn(copyCommonLoaderResources)
dependsOn(deleteDuplicatedCommonLoaderResources)
}
runClient {
dependsOn(copyCoreResources)
dependsOn(copyAccessWidener)
dependsOn(copyCommonLoaderResources)
dependsOn(deleteDuplicatedCommonLoaderResources)
jvmArgs "-XX:-OmitStackTraceInFastThrow"
finalizedBy(deleteResources)
}
+1 -1
View File
@@ -33,7 +33,7 @@
},
"mixins": [
"DistantHorizons.fabricLike.mixins.json",
"DistantHorizons.fabric.fabricLike.mixins.json",
"DistantHorizons.fabric.mixins.json"
],
+2 -1
View File
@@ -134,7 +134,8 @@ dependencies {
processResources {
dependsOn(copyCoreResources)
dependsOn(copyAccessWidener)
dependsOn(copyCommonLoaderResources)
dependsOn(deleteDuplicatedCommonLoaderResources)
}
//remapJar {
+4 -2
View File
@@ -92,12 +92,14 @@ task deleteResources(type: Delete) {
processResources {
dependsOn(copyCoreResources)
dependsOn(copyAccessWidener)
dependsOn(copyCommonLoaderResources)
dependsOn(deleteDuplicatedCommonLoaderResources)
}
runClient {
dependsOn(copyCoreResources)
dependsOn(copyAccessWidener)
dependsOn(copyCommonLoaderResources)
dependsOn(deleteDuplicatedCommonLoaderResources)
jvmArgs "-XX:-OmitStackTraceInFastThrow"
finalizedBy(deleteResources)
}
+1 -1
View File
@@ -57,7 +57,7 @@
"access_widener": "lod.accesswidener",
"mixin": [
"DistantHorizons.fabricLike.mixins.json",
"DistantHorizons.quilt.fabricLike.mixins.json",
"DistantHorizons.quilt.mixins.json"
],