Merge branch 'main' of gitlab.com:jeseibel/minecraft-lod-mod

This commit is contained in:
James Seibel
2023-04-27 20:36:13 -05:00
7 changed files with 112 additions and 75 deletions
+94 -62
View File
@@ -89,7 +89,7 @@ forgix {
}
subprojects { p ->
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge")"
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverWeAddLaterOn")"
// Useful later on so we dont have duplicated code
def isMinecraftSubProject = p != project(":core") && p != project(":api")
@@ -156,8 +156,9 @@ subprojects { p ->
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
// Log4j
shadowMe("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
shadowMe("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
// TODO: Change to shadowMe later to work in the standalone jar
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
// JOML
implementation("org.joml:joml:${rootProject.joml_version}")
@@ -268,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"
@@ -421,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) {
@@ -490,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 {
+6 -4
View File
@@ -1,5 +1,5 @@
plugins {
id "org.quiltmc.loom" version "0.12.+"
id "org.quiltmc.loom" version "1.1.+"
}
loom {
@@ -54,7 +54,7 @@ dependencies {
// Quilted Fabric API
modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilted_api_version}" // For now until quilt has a better way of doing this, just use quilt's qfapi
// addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.quilted_api_version))
// addModJar(fabricApi.module("fabric-events-interaction-v0" , rootProject.quilted_api_version))
// addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.quilted_api_version))
// addModJar(fabricApi.module("fabric-key-binding-api-v1", rootProject.quilted_api_version))
// addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.quilted_api_version))
@@ -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)
}
+2 -2
View File
@@ -56,8 +56,8 @@
},
"access_widener": "lod.accesswidener",
"mixins": [
"DistantHorizons.fabricLike.mixins.json",
"mixin": [
"DistantHorizons.quilt.fabricLike.mixins.json",
"DistantHorizons.quilt.mixins.json"
],
+2 -2
View File
@@ -33,8 +33,8 @@ fabric_api_version=0.67.1+1.18.2
enable_bclib=1
enable_canvas=0
quilt_loader_version=0.18.4-pre.1-SNAPSHOT
quilted_api_version=1.0.0-beta.9+0.51.1-1.18.2-SNAPSHOT
quilt_loader_version=0.19.0-beta.13
quilted_api_version=1.0.0-beta.28+0.67.0-1.18.2
# Quilt mod versions
### Most of the time quilt uses the same stuff as fabric, so this is empty atm ###