Attempt to move over to Unimined

This commit is contained in:
Cutiepie
2024-01-30 17:44:50 +11:00
parent 9a8f14c7d3
commit 6d7b557c36
14 changed files with 130 additions and 362 deletions
+42 -55
View File
@@ -13,13 +13,8 @@ plugins {
// // Provides mc libraries to core
// id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false
// Architectury is used here only as a replacement for forge's own loom
// id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "fabric-loom" version "1.4-SNAPSHOT" apply false
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' apply false
id 'org.spongepowered.mixin' version '0.7.+' apply false
id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false
// Use unimined which is our one in all solution to minecraft loaders
id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false
}
/**
@@ -114,18 +109,30 @@ subprojects { p ->
if (p == project(":core"))
apply plugin: "application"
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
if (p != project(":common") && isMinecraftSubProject) {
apply plugin: "xyz.wagyourtail.unimined"
// Apply forge's loom
if (
(findProject(":forge") && p == project(":forge")) ||
(findProject(":neoforge") && p == project(":neoforge"))
) {
// apply plugin: 'net.minecraftforge.gradle'
// apply plugin: 'org.spongepowered.mixin'
// apply plugin: 'org.parchmentmc.librarian.forgegradle'
unimined.minecraft(sourceSets.main, true) {
version minecraft_version
/* The code below creates the access transformer file */
new AWToAT().remap(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), accessWidenerVersion)
def parchmentVersionParts = parchment_version.split(":")
mappings {
mojmap()
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
devNamespace "mojmap"
}
}
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
source(project(":api").sourceSets.main.allSource)
source(project(":core").sourceSets.main.allSource)
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
@@ -138,52 +145,33 @@ subprojects { p ->
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
// extends the shadowJar configuration
shadowMe
shadowMe // Configuration that contains coreProjects
shade // Configuration that doesn't contain coreProjects
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMe)
implementation.extendsFrom(shade)
// Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way)
minecraftLibraries.extendsFrom(shade)
// Configuration fpr core & api
coreProjects
shadowMe.extendsFrom(coreProjects)
// FIXME this additional configuration is necessary because forge
// needs forgeRuntimeLibrary, although adding it to shadowMe
// causes runtime issues where the libraries aren't properly added
forgeShadowMe
// this should match shadowMe pretty closely
implementation.extendsFrom(forgeShadowMe)
shadowMe.extendsFrom(forgeShadowMe)
runtimeOnly.extendsFrom(forgeShadowMe)
if (isMinecraftSubProject && p != project(":common")) {
// Shadow common
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
if (findProject(":forge"))
developmentForge.extendsFrom common
implementation.extendsFrom common
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom common
implementation.extendsFrom common
compileClasspath.extendsFrom coreProjects
runtimeClasspath.extendsFrom coreProjects
if (findProject(":forge"))
developmentForge.extendsFrom coreProjects
implementation.extendsFrom coreProjects
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom coreProjects
implementation.extendsFrom coreProjects
implementation.extendsFrom common
implementation.extendsFrom coreProjects
if (findProject(":fabricLike") && p != project(":fabricLike")) {
// Shadow fabricLike
fabricLike
shadowFabricLike
compileClasspath.extendsFrom fabricLike
runtimeClasspath.extendsFrom fabricLike
implementation.extendsFrom fabricLike
}
}
}
@@ -202,7 +190,6 @@ subprojects { p ->
// shared dependencies //
//=====================//
// Manifold
if (isMinecraftSubProject) {
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
@@ -223,24 +210,24 @@ subprojects { p ->
implementation("junit:junit:4.13")
// Compression
forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}")
shade("org.lz4:lz4-java:${rootProject.lz4_version}")
// Sqlite Database
forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
shade("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
// NightConfig (includes Toml & Json)
forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
shade("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
// SVG (not needed atm)
// forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// Netty
// Breaks 1.16.5
//forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}")
//shade("io.netty:netty-all:${rootProject.netty_version}")
// Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
shade("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it
}
@@ -291,7 +278,7 @@ subprojects { p ->
shadowJar {
configurations = [project.configurations.shadowMe]
configurations = [project.configurations.shadowMe, project.configurations.shade]
if (isMinecraftSubProject && p != project(":common")) {
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location
@@ -9,7 +9,7 @@ import net.minecraft.world.level.chunk.storage.RegionFile;
import net.minecraft.world.level.chunk.storage.RegionFileStorage;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.file.Files;
+31 -40
View File
@@ -1,22 +1,7 @@
apply plugin: "fabric-loom"
loom {
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
// "runs" isn't required, but when we do need it then it can be useful
runs {
client {
client()
setConfigName("Fabric Client")
ideConfigGenerated(true)
runDir("../run")
}
server {
server()
setConfigName("Fabric Server")
ideConfigGenerated(true)
runDir("../run")
}
unimined.minecraft {
fabric {
loader rootProject.fabric_loader_version
accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))
}
}
@@ -32,27 +17,31 @@ def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { modCompileOnly(path) }
dependencies { compileOnly(path) }
}
// TODO: There currently seems to be a bug which causes the regular addModJar to not work, swap back to the regular addModJar when fixed
def addModJar_(path) {
dependencies {
modImplementation(path)
include(path)
}
}
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.layered() {
// Mojmap mappings
officialMojangMappings()
// Parchment mappings (it adds parameter mappings & javadoc)
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
// Fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
annotationProcessor "javax.annotation:javax.annotation-api:1.3.2"
implementation("javax.annotation:javax.annotation-api:1.3.2")
runtimeOnly "javax.annotation:javax.annotation-api:1.3.2"
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
modImplementation "javax.annotation:javax.annotation-api:1.3.2"
// Fabric API
addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-api-base", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-resource-loader-v0", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-events-interaction-v0", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
addModJar_(fabricApi.fabricModule("fabric-networking-api-v1", rootProject.fabric_api_version))
// Mod Menu
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
@@ -123,11 +112,13 @@ processResources {
dependsOn(copyCommonLoaderResources)
}
runClient {
dependsOn(copyCoreResources)
dependsOn(copyCommonLoaderResources)
afterEvaluate {
runClient {
dependsOn(copyCoreResources)
dependsOn(copyCommonLoaderResources)
// jvmArgs([ "-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg ])
finalizedBy(deleteResources)
finalizedBy(deleteResources)
}
}
//jar {
+19 -154
View File
@@ -1,154 +1,19 @@
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
//sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
//architectury {
// platformSetupLoomIde()
// forge()
//}
//loom {
// forge {
// convertAccessWideners.set(true)
// extraAccessWideners.add("lod.accesswidener")
// mixinConfigs("DistantHorizons.mixins.json")
// }
//}
//loom {
// silentMojangMappingsLicense() // Shut the licencing warning
// accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
//
// forge {
// convertAccessWideners = true
// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
//
// mixinConfigs = [
// "DistantHorizons.forge.mixins.json"
// ]
// }
//
// // "runs" isn't required, but when we do need it then it can be useful
// runs {
// client {
// client()
// setConfigName("Forge Client")
// ideConfigGenerated(true)
// runDir("../run")
//// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
// }
// server {
// server()
// setConfigName("Forge Server")
// ideConfigGenerated(true)
// runDir("../run")
// }
// }
//}
minecraft {
mappings channel: 'official', version: minecraft_version
accessTransformer = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
args "-mixins.config=${mod_name}.forge.mixins.json"
mods {
modClientRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":api").sourceSets.main
source project(":core").sourceSets.main
}
}
property 'forge.enabledGameTestNamespaces', mod_id
property 'forge.logging.console.level', 'debug'
properties 'mixin.env.remapRefMap': 'true'
property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg"
}
server {
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Server'
args "-mixins.config=${mod_name}.forge.mixins.json"
mods {
modServerRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":api").sourceSets.main
source project(":core").sourceSets.main
}
}
property 'forge.logging.console.level', 'debug'
properties 'mixin.env.remapRefMap': 'true'
property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg"
}
data {
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
taskName 'Data'
args "-mixins.config=${mod_name}.forge.mixins.json"
mods {
modDataRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":api").sourceSets.main
source project(":core").sourceSets.main
}
}
property 'forge.logging.console.level', 'debug'
}
unimined.minecraft {
minecraftForge {
loader forge_version
mixinConfig("DistantHorizons.forge.mixins.json")
accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")))
}
}
sourceSets.main.resources.srcDir 'src/generated/resources'
//remapJar {
// inputFile = shadowJar.archiveFile
// dependsOn shadowJar
//// classifier null
//}
shadowJar {
finalizedBy 'reobfShadowJar'
}
jar.dependsOn('shadowJar')
reobf {
shadowJar {}
}
minecraft.runs.all {
lazyToken('minecraft_classpath') {
// configurations.implementation.exclude group: 'org.jetbrains', module: 'annotations'
// configurations.implementation.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
// configurations.runtimeLibrary.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
}
def addMod(path, enabled) {
if (enabled == "2")
// dependencies { implementation(path) }
dependencies { implementation(fg.deobf(path)) }
dependencies { modImplementation(path) }
else if (enabled == "1")
// dependencies { modCompileOnly(path) }
dependencies { compileOnly(fg.deobf(path)) }
dependencies { compileOnly(path) }
}
dependencies {
// minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// mappings loom.layered() {
// // Mojmap mappings
// officialMojangMappings()
// // Parchment mappings (it adds parameter mappings & javadoc)
// parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
// }
// Forge
minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
// Architectury API
// if (minecraft_version == "1.16.5") {
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
@@ -164,17 +29,13 @@ dependencies {
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
// annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
// if (System.getProperty("idea.sync.active") != "true") {
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
// }
}
mixin {
add sourceSets.main, "${mod_name}-forge-refmap.json"
}
task deleteResources(type: Delete) {
delete file("build/resources/main")
}
@@ -188,14 +49,18 @@ processResources {
dependsOn(tasks.named('copyAllResources'))
}
//processResources {
// dependsOn(tasks.named('copyAllResources'))
//}
afterEvaluate {
runClient {
dependsOn(tasks.named('copyAllResources'))
finalizedBy(deleteResources)
}
}
//tasks.named('prepareClient') {
// dependsOn(tasks.named('copyAllResources'))
// finalizedBy(deleteResources)
//}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
}
sourcesJar {
@@ -38,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Mixin(DynamicTexture.class)
public abstract class MixinDynamicTexture implements ILightTextureMarker
@@ -19,7 +19,5 @@
"client.MixinOptionsScreen",
"client.MixinTextureUtil"
],
"server": [],
"plugin": "com.seibel.distanthorizons.forge.mixins.ForgeMixinPlugin",
"refmap": "DistantHorizons-forge-refmap.json"
"server": []
}
+6 -1
View File
@@ -23,11 +23,16 @@ issueTrackerURL = "${issues}"
#// Allow any version to be present (or not) on the server
acceptableRemoteVersions = "*"
[[dependencies.distanthorizons]]
modId="forge" #mandatory
mandatory = true # Forge syntax
versionRange="[0,)" #mandatory
ordering="NONE"
side="BOTH"
[[dependencies.distanthorizons]]
modId = "minecraft"
mandatory = true # Forge syntax
type = "required" # Neoforge syntax
versionRange = "${compatible_forgemc_versions}" # Where we set what version of mc it is avalible for
ordering = "AFTER"
side = "BOTH"
-10
View File
@@ -1,10 +0,0 @@
{
"pack": {
"pack_format": 7,
"supported_formats": {
"min_inclusive": 16,
"max_inclusive": 90000
},
"description": "Distant Horizons"
}
}
+20 -91
View File
@@ -1,100 +1,19 @@
plugins {
// Note: This is only needed for multi-loader projects
// The main architectury loom version is set at the start of the root build.gradle
id "architectury-plugin" version "3.4-SNAPSHOT"
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
architectury {
platformSetupLoomIde()
neoForge()
}
repositories {
maven {
name "Neoforge"
url "https://maven.neoforged.net/releases/"
unimined.minecraft {
neoForged {
loader neoforge_version
mixinConfig("DistantHorizons.neoforge.mixins.json")
accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")))
}
}
//loom {
// forge {
// convertAccessWideners.set(true)
// extraAccessWideners.add("lod.accesswidener")
// mixinConfigs("DistantHorizons.mixins.json")
// }
//}
loom {
silentMojangMappingsLicense() // Shut the licencing warning
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
neoForge {
// Access wideners are now defined in the `remapJar.atAccessWideners`
// convertAccessWideners = true
// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
// Mixins are now defined in the `mods.toml`
// mixinConfigs = [
// "DistantHorizons.mixins.json"
// ]
}
mixin {
// Mixins are now defined in the `mods.toml`
// mixinConfigs = [
// "DistantHorizons.mixins.json"
// ]
}
// "runs" isn't required, but when we do need it then it can be useful
runs {
client {
client()
setConfigName("NeoForge Client")
ideConfigGenerated(true)
runDir("../run")
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
}
server {
server()
setConfigName("NeoForge Server")
ideConfigGenerated(true)
runDir("../run")
}
}
}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
atAccessWideners.add("distanthorizons.accesswidener")
}
def addMod(path, enabled) {
if (enabled == "2")
dependencies { implementation(path) }
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { modCompileOnly(path) }
dependencies { compileOnly(path) }
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
// Mojmap mappings
officialMojangMappings()
// Parchment mappings (it adds parameter mappings & javadoc)
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
// Architectury hackishness
// it.mappings "dev.architectury:yarn-mappings-patch-forge:${rootProject.mappings_patch}"
}
// Neoforge
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
// Architectury API
// if (minecraft_version == "1.16.5") {
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
@@ -110,6 +29,8 @@ dependencies {
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
// annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
// if (System.getProperty("idea.sync.active") != "true") {
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
// }
@@ -128,9 +49,17 @@ processResources {
dependsOn(tasks.named('copyAllResources'))
}
tasks.named('runClient') {
dependsOn(tasks.named('copyAllResources'))
finalizedBy(deleteResources)
afterEvaluate {
runClient {
dependsOn(tasks.named('copyAllResources'))
finalizedBy(deleteResources)
}
}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
}
+6
View File
@@ -29,6 +29,12 @@ pluginManagement {
name "ParchmentMC"
url "https://maven.parchmentmc.org"
}
maven {
url = "https://maven.wagyourtail.xyz/releases"
}
maven {
url = "https://maven.wagyourtail.xyz/snapshots"
}
mavenCentral()
gradlePluginPortal()
-1
View File
@@ -2,7 +2,6 @@
java_version=17
minecraft_version=1.20.1
parchment_version=1.20.1:2023.09.03
parchment_forge_version=1.20.1-2023.09.03
compatible_minecraft_versions=["1.20", "1.20.1"]
accessWidenerVersion=1_20
builds_for=fabric,forge
-1
View File
@@ -2,7 +2,6 @@
java_version=17
minecraft_version=1.20.2
parchment_version=1.20.1:2023.09.03
parchment_forge_version=1.20.1-2023.09.03
compatible_minecraft_versions=["1.20.2"]
accessWidenerVersion=1_20_2
builds_for=fabric,forge
+2 -3
View File
@@ -2,10 +2,9 @@
java_version=17
minecraft_version=1.20.4
parchment_version=1.20.2:2023.12.10
parchment_forge_version=1.20.2-2023.12.10
compatible_minecraft_versions=["1.20.3", "1.20.4"]
accessWidenerVersion=1_20_2
builds_for=forge,fabric
builds_for=fabric,neoforge
# Fabric loader
fabric_loader_version=0.15.1
@@ -39,7 +38,7 @@ fabric_api_version=0.91.2+1.20.4
# (Neo)Forge loader
forge_version=49.0.16
neoforge_version=20.4.83-beta
neoforge_version=118-beta
# (Neo)Forge mod versions
starlight_version_forge=
terraforged_version=