From 8657ce930f838b0b5e69a2be068e1590ddb1fae8 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:32:58 -0400 Subject: [PATCH 1/7] Test: Baritone --- build.gradle.kts | 3 +++ common/build.gradle.kts | 9 +++------ fabric/build.gradle.kts | 7 ++++++- forge/build.gradle.kts | 16 +++++++++------- neoforge/build.gradle.kts | 6 ++++-- quilt/build.gradle.kts | 6 +++--- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 59e17e822..519ad6993 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,17 +46,20 @@ subprojects { isCanBeConsumed = false isCanBeResolved = true } + val shadow = named("shadowJar") { archiveVersion = versionWithMCVersion archiveClassifier.set("shadow") configurations = listOf(shadowCommon) } + named("remapJar") { dependsOn(shadow) inputFile = shadow.flatMap { it.archiveFile } archiveVersion = versionWithMCVersion archiveClassifier = "" } + jar { enabled = false } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 1b0003e80..58ca038f9 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -11,11 +11,8 @@ loom { } repositories { + maven("https://impactdevelopment.github.io/maven/") maven("https://maven.fabricmc.net/") - maven("https://jitpack.io") - - mavenCentral() - mavenLocal() } dependencies { @@ -27,9 +24,9 @@ dependencies { modApi("dev.architectury:architectury:$architecturyVersion") // Add dependencies on the required Kotlin modules. - modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion") implementation("org.reflections:reflections:0.10.2") - implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) + modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion") + modImplementation("baritone-api:baritone-api:1.10.2") } // Avoid nested jars diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index ea993a545..e0c3f1a34 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -15,6 +15,10 @@ loom { enableTransitiveAccessWideners.set(true) } +repositories { + maven("https://impactdevelopment.github.io/maven/") +} + val common: Configuration by configurations.creating { configurations.compileClasspath.get().extendsFrom(this) configurations.runtimeClasspath.get().extendsFrom(this) @@ -49,9 +53,10 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.27.0-GA") + includeLib("nether-pathfinder:nether-pathfinder:1.4.1") // Add mods to the mod jar - // includeMod(...) + includeMod("baritone-api:baritone-unoptimized-fabric:1.10.2") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 38c4b9998..00a308334 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -35,6 +35,7 @@ loom { repositories { maven("https://thedarkcolour.github.io/KotlinForForge/") maven("https://cursemaven.com") + maven("https://impactdevelopment.github.io/maven/") } val common: Configuration by configurations.creating { @@ -70,20 +71,21 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.27.0-GA") - - implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") - compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) + includeLib("nether-pathfinder:nether-pathfinder:1.4.1") // Add mods to the mod jar includeMod("thedarkcolour:kotlinforforge:$kotlinForgeVersion") - - // Bugfixes - compileOnly(kotlin("stdlib")) // Hack https://github.com/thedarkcolour/KotlinForForge/issues/93 + includeMod("baritone:baritone-unoptimized-forge:1.10.2") // Common (Do not touch) - common(project(":common", configuration = "namedElements")) { isTransitive = false } // We cannot common here because it is treated as a different mod and forge will panic + common(project(":common", configuration = "namedElements")) { isTransitive = false } shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } + // Others + implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") + compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) + compileOnly(kotlin("stdlib")) // Hack https://github.com/thedarkcolour/KotlinForForge/issues/93 + // Finish the configuration setupConfigurations() } diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 8761957aa..bcea1ee38 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -17,6 +17,7 @@ loom { repositories { maven("https://maven.neoforged.net/releases/") maven("https://thedarkcolour.github.io/KotlinForForge/") + maven("https://impactdevelopment.github.io/maven/") } val common: Configuration by configurations.creating { @@ -35,7 +36,7 @@ fun DependencyHandlerScope.setupConfigurations() { } includeMod.dependencies.forEach { - implementation(it) + modImplementation(it) } } @@ -47,10 +48,11 @@ dependencies { modApi("dev.architectury:architectury-neoforge:$architecturyVersion") // Add dependencies on the required Kotlin modules. - // includeLib(...) + includeLib("nether-pathfinder:nether-pathfinder:1.4.1") // Add mods to the mod jar includeMod("thedarkcolour:kotlinforforge-neoforge:$kotlinForgeVersion") + includeMod("baritone-api:baritone-unoptimized-neoforge:1.10.2") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } diff --git a/quilt/build.gradle.kts b/quilt/build.gradle.kts index b1d3e7e5e..7601e8e4a 100644 --- a/quilt/build.gradle.kts +++ b/quilt/build.gradle.kts @@ -24,6 +24,7 @@ loom { repositories { maven("https://maven.quiltmc.org/repository/release/") + maven("https://impactdevelopment.github.io/maven/") } val common: Configuration by configurations.creating { @@ -43,7 +44,6 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { modImplementation(it) - include(it) } } @@ -66,10 +66,10 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.27.0-GA") + includeLib("nether-pathfinder:nether-pathfinder:1.4.1") // Add mods to the mod jar - // includeMod(...) - + includeMod("baritone-api:baritone-unoptimized-fabric:1.10.2") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } From d97d8aa0a918d1ad78274240ebf7173d70a12942 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:13:41 -0400 Subject: [PATCH 2/7] Refactor!: Single version, removed kotlin modloader --- build.gradle.kts | 12 +-- common/build.gradle.kts | 11 ++- fabric/build.gradle.kts | 25 ++--- .../kotlin/com/lambda/fabric/LambdaFabric.kt | 2 +- fabric/src/main/resources/fabric.mod.json | 12 +-- forge/build.gradle.kts | 36 ++++--- .../kotlin/com/lambda/forge/LambdaForge.kt | 5 +- forge/src/main/resources/META-INF/mods.toml | 57 +++++------ gradle.properties | 4 +- neoforge/build.gradle.kts | 30 ++++-- .../com/lambda/neoforge/LambdaNeoForge.kt | 2 +- .../src/main/resources/META-INF/mods.toml | 66 ++++++------- quilt/build.gradle.kts | 99 ------------------- quilt/gradle.properties | 1 - .../com/lambda/fabric/LoaderInfoImpl.kt | 13 --- .../kotlin/com/lambda/quilt/LambdaQuilt.kt | 17 ---- .../kotlin/com/lambda/quilt/LoaderInfoImpl.kt | 12 --- quilt/src/main/resources/quilt.mod.json | 53 ---------- settings.gradle.kts | 2 +- 19 files changed, 137 insertions(+), 322 deletions(-) delete mode 100644 quilt/build.gradle.kts delete mode 100644 quilt/gradle.properties delete mode 100644 quilt/src/main/kotlin/com/lambda/fabric/LoaderInfoImpl.kt delete mode 100644 quilt/src/main/kotlin/com/lambda/quilt/LambdaQuilt.kt delete mode 100644 quilt/src/main/kotlin/com/lambda/quilt/LoaderInfoImpl.kt delete mode 100644 quilt/src/main/resources/quilt.mod.json diff --git a/build.gradle.kts b/build.gradle.kts index 519ad6993..b4e93df19 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ val yarnMappings = property("yarn_mappings").toString() val libs = file("libs") plugins { - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "1.9.23" id("org.jetbrains.dokka") version "1.9.20" id("architectury-plugin") version "3.4-SNAPSHOT" id("dev.architectury.loom") version "1.5-SNAPSHOT" apply false @@ -26,14 +26,8 @@ subprojects { apply(plugin = "org.jetbrains.dokka") dependencies { - if (path == ":quilt") { - "minecraft"("com.mojang:minecraft:1.20.2") - "mappings"("net.fabricmc:yarn:1.20.2+build.3:v2") - } - else { - "minecraft"("com.mojang:minecraft:$minecraftVersion") - "mappings"("net.fabricmc:yarn:$yarnMappings:v2") - } + "minecraft"("com.mojang:minecraft:$minecraftVersion") + "mappings"("net.fabricmc:yarn:$yarnMappings:v2") } if (path == ":common") return@subprojects diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 58ca038f9..df63ada30 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,9 +1,10 @@ val fabricLoaderVersion = property("fabric_loader_version").toString() -val fabricKotlinVersion = property("fabric_kotlin_version").toString() val mixinExtrasVersion = property("mixinextras_version").toString() +val kotlinVersion = property("kotlin_version").toString() +val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() -architectury { common("fabric", "forge", "neoforge", "quilt") } +architectury { common("fabric", "forge", "neoforge") } loom { silentMojangMappingsLicense() @@ -11,7 +12,6 @@ loom { } repositories { - maven("https://impactdevelopment.github.io/maven/") maven("https://maven.fabricmc.net/") } @@ -25,8 +25,9 @@ dependencies { // Add dependencies on the required Kotlin modules. implementation("org.reflections:reflections:0.10.2") - modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion") - modImplementation("baritone-api:baritone-api:1.10.2") + + // Add Kotlin + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") } // Avoid nested jars diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index e0c3f1a34..29f91a36f 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,6 +1,7 @@ val fabricLoaderVersion = property("fabric_loader_version").toString() val fabricApiVersion = property("fabric_api_version").toString() -val fabricKotlinVersion = property("fabric_kotlin_version").toString() +val kotlinVersion = property("kotlin_version").toString() +val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() architectury { @@ -15,10 +16,6 @@ loom { enableTransitiveAccessWideners.set(true) } -repositories { - maven("https://impactdevelopment.github.io/maven/") -} - val common: Configuration by configurations.creating { configurations.compileClasspath.get().extendsFrom(this) configurations.runtimeClasspath.get().extendsFrom(this) @@ -27,6 +24,7 @@ val common: Configuration by configurations.creating { val includeLib: Configuration by configurations.creating val includeMod: Configuration by configurations.creating +val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { @@ -37,26 +35,29 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { modImplementation(it) } + + shadowInclude.dependencies.forEach { + implementation(it) + shadowCommon(it) + } } dependencies { // Fabric API (Do not touch) modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") - modApi("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion") // Remove the following line if you don't want to depend on the API modApi("dev.architectury:architectury-fabric:$architecturyVersion") - // Kotlin for Fabric - modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion") - // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.27.0-GA") - includeLib("nether-pathfinder:nether-pathfinder:1.4.1") // Add mods to the mod jar - includeMod("baritone-api:baritone-unoptimized-fabric:1.10.2") + // includeMod(...) + + // Add Kotlin + shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } @@ -75,7 +76,7 @@ tasks { expand(getProperties()) expand(mutableMapOf( "group" to project.group, - "version" to project.version + "version" to project.version, )) } } diff --git a/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt b/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt index 1b6840aa8..a3ce3cd12 100644 --- a/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt +++ b/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt @@ -6,7 +6,7 @@ import com.lambda.Lambda.LOG import com.lambda.Lambda.MOD_NAME import com.lambda.Lambda.VERSION -object LambdaFabric : ClientModInitializer { +class LambdaFabric : ClientModInitializer { override fun onInitializeClient() { Lambda.initialize() LOG.info("$MOD_NAME Fabric $VERSION initialized.") diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 21b055a12..04047de73 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -17,7 +17,6 @@ "entrypoints": { "client": [ { - "adapter": "kotlin", "value": "com.lambda.fabric.LambdaFabric" } ] @@ -26,11 +25,10 @@ "lambda.mixins.common.json" ], "depends": { - "fabricloader": ">=0.14.24", - "fabric-api": ">=0.83.0+1.20", - "architectury": ">=9.0.6", - "minecraft": ">=1.20.0", - "java": ">=17", - "fabric-language-kotlin": ">=${fabric_kotlin_version}" + "fabricloader": ">=0.15.1", + "fabric-api": ">=0.91.3+1.20.4", + "architectury": ">=11.0.8", + "minecraft": "1.20.4", + "java": ">=17" } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 00a308334..07c463587 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,5 +1,6 @@ val forgeVersion = property("forge_version").toString() -val kotlinForgeVersion = property("kotlin_forge_version").toString() +val kotlinVersion = property("kotlin_version").toString() +val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() val mixinExtrasVersion = property("mixinextras_version").toString() @@ -33,9 +34,7 @@ loom { } repositories { - maven("https://thedarkcolour.github.io/KotlinForForge/") maven("https://cursemaven.com") - maven("https://impactdevelopment.github.io/maven/") } val common: Configuration by configurations.creating { @@ -46,6 +45,7 @@ val common: Configuration by configurations.creating { val includeLib: Configuration by configurations.creating val includeMod: Configuration by configurations.creating +val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { @@ -59,6 +59,11 @@ fun DependencyHandlerScope.setupConfigurations() { implementation(it) forgeRuntimeLibrary(it) } + + shadowInclude.dependencies.forEach { + implementation(it) + shadowCommon(it) + } } dependencies { @@ -70,21 +75,22 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") - includeLib("org.javassist:javassist:3.27.0-GA") - includeLib("nether-pathfinder:nether-pathfinder:1.4.1") + includeLib("org.javassist:javassist:3.30.0-GA") // Add mods to the mod jar - includeMod("thedarkcolour:kotlinforforge:$kotlinForgeVersion") - includeMod("baritone:baritone-unoptimized-forge:1.10.2") + // includeMod(...) - // Common (Do not touch) - common(project(":common", configuration = "namedElements")) { isTransitive = false } - shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } + // Add Kotlin + shadowInclude("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") + shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") - // Others + // MixinExtras implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) - compileOnly(kotlin("stdlib")) // Hack https://github.com/thedarkcolour/KotlinForForge/issues/93 + + // Common (Do not touch) + common(project(":common", configuration = "namedElements")) { isTransitive = false } + shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } // Finish the configuration setupConfigurations() @@ -92,11 +98,15 @@ dependencies { tasks { processResources { + inputs.property("group", project.group) inputs.property("version", project.version) filesMatching("META-INF/mods.toml") { expand(getProperties()) - expand(mutableMapOf("version" to project.version)) + expand(mutableMapOf( + "group" to project.group, + "version" to project.version, + )) } } } diff --git a/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt b/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt index 97f6daaa9..c279f6a82 100644 --- a/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt +++ b/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt @@ -1,13 +1,14 @@ package com.lambda.forge -import net.minecraftforge.fml.common.Mod import com.lambda.Lambda import com.lambda.Lambda.LOG import com.lambda.Lambda.MOD_NAME import com.lambda.Lambda.VERSION +import net.minecraftforge.fml.common.Mod + @Mod(Lambda.MOD_ID) -object LambdaForge { +class LambdaForge { init { Lambda.initialize() LOG.info("$MOD_NAME Forge $VERSION initialized.") diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index a38474502..c975d8b86 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,41 +1,34 @@ -modLoader = "kotlinforforge" -loaderVersion = "[4,)" +modLoader = "javafml" +loaderVersion = "[48,)" license = "GNU General Public License v3.0" +issueTrackerURL = "https://github.com/lambda-client/lambda/issues [[mods]] -modId = "lambda" -version = "${version}" -displayName = "Lambda" -authors = "${authors}" -description = ''' -''' -logoFile = "assets/lambda/lambda.png" -displayTest = "IGNORE_ALL_VERSION" + modId = "lambda" + version = "${mod_version}" + displayName = "Lambda" + authors = "${authors}" + description = "${mod_description}" + logoFile = "assets/lambda/lambda.png" + displayTest = "IGNORE_ALL_VERSION" [[dependencies.lambda]] -modId = "forge" -mandatory = true -versionRange = "[44,)" -ordering = "NONE" -side = "CLIENT" + modId = "forge" + mandatory = true + versionRange = "[49,)" + ordering = "NONE" + side = "CLIENT" [[dependencies.lambda]] -modId = "minecraft" -mandatory = true -versionRange = "[1.19.3,1.21)" -ordering = "NONE" -side = "CLIENT" + modId = "minecraft" + mandatory = true + versionRange = "[1.20.4,)" + ordering = "NONE" + side = "CLIENT" [[dependencies.lambda]] -modId = "kotlinforforge" -mandatory = true -versionRange = "[4,)" -ordering = "AFTER" -side = "CLIENT" - -[[dependencies.lambda]] -modId = "architectury" -mandatory = true -versionRange = "[7.1.86,)" -ordering = "AFTER" -side = "CLIENT" + modId = "architectury" + mandatory = true + versionRange = "[11.0.7,)" + ordering = "NONE" + side = "CLIENT" diff --git a/gradle.properties b/gradle.properties index 3e6e6b666..84648d54c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,7 @@ authors=Constructor # General minecraft_version=1.20.4 mixinextras_version=0.3.5 +kotlin_version=1.9.23 kotlinx_coroutines_version=1.8.0 # Architectury https://docs.architectury.dev/start @@ -18,11 +19,9 @@ architectury_version=11.1.13 fabric_loader_version=0.15.7 yarn_mappings=1.20.4+build.3 fabric_api_version=0.96.4+1.20.4 -fabric_kotlin_version=1.10.18+kotlin.1.9.22 # Forge https://files.minecraftforge.net/ forge_version=1.20.4-49.0.31 -kotlin_forge_version=4.10.0 # NeoForge https://neoforged.net neo_version=20.4.196 @@ -30,7 +29,6 @@ neo_version=20.4.196 # Quilt https://quiltmc.org/ quilt_version=0.24.0 quilted_fabric_version=8.0.0-alpha.4+0.91.6-1.20.2 -kotlin_quilt_version=3.0.0+kt.1.9.22+flk.1.10.17 # Kotlin https://kotlinlang.org/ kotlin.code.style=official diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index bcea1ee38..079e02be8 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,5 +1,5 @@ val neoVersion = property("neo_version").toString() -val kotlinForgeVersion = property("kotlin_forge_version").toString() +val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() val mixinExtrasVersion = property("mixinextras_version").toString() @@ -16,8 +16,6 @@ loom { repositories { maven("https://maven.neoforged.net/releases/") - maven("https://thedarkcolour.github.io/KotlinForForge/") - maven("https://impactdevelopment.github.io/maven/") } val common: Configuration by configurations.creating { @@ -28,6 +26,7 @@ val common: Configuration by configurations.creating { val includeLib: Configuration by configurations.creating val includeMod: Configuration by configurations.creating +val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { @@ -37,6 +36,12 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { modImplementation(it) + include(it) + } + + shadowInclude.dependencies.forEach { + implementation(it) + shadowCommon(it) } } @@ -48,11 +53,14 @@ dependencies { modApi("dev.architectury:architectury-neoforge:$architecturyVersion") // Add dependencies on the required Kotlin modules. - includeLib("nether-pathfinder:nether-pathfinder:1.4.1") + includeLib("org.reflections:reflections:0.10.2") + includeLib("org.javassist:javassist:3.30.0-GA") // Add mods to the mod jar - includeMod("thedarkcolour:kotlinforforge-neoforge:$kotlinForgeVersion") - includeMod("baritone-api:baritone-unoptimized-neoforge:1.10.2") + // includeMod(...) + + // Add Kotlin + shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } @@ -64,11 +72,19 @@ dependencies { tasks { processResources { + inputs.property("group", project.group) inputs.property("version", project.version) filesMatching("META-INF/mods.toml") { expand(getProperties()) - expand(mutableMapOf("version" to project.version)) + expand(mutableMapOf( + "group" to project.group, + "version" to project.version, + )) } } + + remapJar { + atAccessWideners.add("lambda.accesswidener") + } } diff --git a/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt b/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt index 971f595b8..805c126e3 100644 --- a/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt +++ b/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt @@ -7,7 +7,7 @@ import com.lambda.Lambda.MOD_NAME import com.lambda.Lambda.VERSION @Mod(Lambda.MOD_ID) -object LambdaNeoForge { +class LambdaNeoForge { init { Lambda.initialize() LOG.info("$MOD_NAME NeoForge $VERSION initialized.") diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index b0abbeebb..41a6b83bc 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -1,44 +1,42 @@ -modLoader = "kotlinforforge" -loaderVersion = "[4,)" +modLoader = "javafml" +loaderVersion = "[2,)" license = "GNU General Public License v3.0" +issueTrackerURL = "https://github.com/lambda-client/lambda/issues +#updateJSONURL = "https://raw.githubusercontent.com/lambda-client/lambda/main/update.json" [[mods]] -modId = "lambda" -version = "${version}" -displayName = "Lambda" -authors = "${authors}" -description = "${description}" -logoFile = "assets/lambda/lambda.png" -displayTest = "IGNORE_ALL_VERSION" + modId = "lambda" + version = "${mod_version}" + displayName = "Lambda" + authors = "${authors}" + description = "${mod_description}" + logoFile = "assets/lambda/lambda.png" + displayTest = "IGNORE_ALL_VERSION" [[dependencies.lambda]] -modId = "neoforge" -mandatory = true -type = "required" -versionRange = "[20.2,)" -ordering = "NONE" -side = "CLIENT" + modId = "neoforge" + mandatory = true + type = "required" + versionRange = "[20.4.0,)" + ordering = "NONE" + side = "CLIENT" [[dependencies.lambda]] -modId = "minecraft" -mandatory = true -type = "required" -versionRange = "[1.20.2,1.21)" -ordering = "NONE" -side = "CLIENT" + modId = "minecraft" + mandatory = true + type = "required" + versionRange = "[1.20.4,)" + ordering = "NONE" + side = "CLIENT" [[dependencies.lambda]] -modId = "kotlinforforge" -mandatory = true -type = "required" -versionRange = "[4,)" -ordering = "AFTER" -side = "CLIENT" + modId = "architectury" + mandatory = true + type = "required" + versionRange = "[11.0.7,)" + ordering = "NONE" + side = "CLIENT" -[[dependencies.lambda]] -modId = "architectury" -mandatory = true -type = "required" -versionRange = "[10.1.19,)" -ordering = "AFTER" -side = "CLIENT" +[[mixins]] + config = "lambda.mixins.common.json" + environment = "client" diff --git a/quilt/build.gradle.kts b/quilt/build.gradle.kts deleted file mode 100644 index 7601e8e4a..000000000 --- a/quilt/build.gradle.kts +++ /dev/null @@ -1,99 +0,0 @@ -val quiltVersion = property("quilt_version").toString() -val quiltedFabricVersion = property("quilted_fabric_version").toString() -val kotlinQuiltVersion = property("kotlin_quilt_version").toString() -val architecturyVersion = /*property("architectury_version").toString()*/ "10.1.19" -val kotlinxCoroutineVersion = property("kotlinx_coroutines_version").toString() - -architectury { - platformSetupLoomIde() - loader("quilt") -} - -base.archivesName.set("${base.archivesName.get()}-quilt") - -loom { - accessWidenerPath.set(project(":common").loom.accessWidenerPath) - enableTransitiveAccessWideners.set(true) - - mods { - register("quilt") { - sourceSet("main", project(":quilt")) - } - } -} - -repositories { - maven("https://maven.quiltmc.org/repository/release/") - maven("https://impactdevelopment.github.io/maven/") -} - -val common: Configuration by configurations.creating { - configurations.compileClasspath.get().extendsFrom(this) - configurations.runtimeClasspath.get().extendsFrom(this) - configurations["developmentQuilt"].extendsFrom(this) -} - -val includeLib: Configuration by configurations.creating -val includeMod: Configuration by configurations.creating - -fun DependencyHandlerScope.setupConfigurations() { - includeLib.dependencies.forEach { - implementation(it) - include(it) - } - - includeMod.dependencies.forEach { - modImplementation(it) - } -} - -dependencies { - // Quilt Loader - modImplementation("org.quiltmc:quilt-loader:$quiltVersion") - - // Quilted Fabric API - modApi("org.quiltmc.quilted-fabric-api:quilted-fabric-api:$quiltedFabricVersion") - - // Remove the following line if you don't want to depend on the API - modApi("dev.architectury:architectury-fabric:$architecturyVersion") { - exclude("net.fabricmc") - exclude("net.fabricmc.fabric-api") - } - - // Kotlin for Quilt - modImplementation("org.quiltmc.quilt-kotlin-libraries:quilt-kotlin-libraries:$kotlinQuiltVersion") - - // Add dependencies on the required Kotlin modules. - includeLib("org.reflections:reflections:0.10.2") - includeLib("org.javassist:javassist:3.27.0-GA") - includeLib("nether-pathfinder:nether-pathfinder:1.4.1") - - // Add mods to the mod jar - includeMod("baritone-api:baritone-unoptimized-fabric:1.10.2") - - // Common (Do not touch) - common(project(":common", configuration = "namedElements")) { isTransitive = false } - shadowCommon(project(":common", configuration = "transformProductionQuilt")) { isTransitive = false } - - // Finish the configuration - setupConfigurations() -} - -tasks { - processResources { - inputs.property("group", project.group) - inputs.property("version", project.version) - - filesMatching("quilt.mod.json") { - expand(getProperties()) - expand(mutableMapOf( - "group" to project.group, - "version" to project.version - )) - } - } - - remapJar { - injectAccessWidener.set(true) - } -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 4fb20b837..000000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=quilt diff --git a/quilt/src/main/kotlin/com/lambda/fabric/LoaderInfoImpl.kt b/quilt/src/main/kotlin/com/lambda/fabric/LoaderInfoImpl.kt deleted file mode 100644 index 74b99c0be..000000000 --- a/quilt/src/main/kotlin/com/lambda/fabric/LoaderInfoImpl.kt +++ /dev/null @@ -1,13 +0,0 @@ -@file:Suppress("deprecation") - -package com.lambda.fabric - -import net.fabricmc.loader.api.FabricLoader - -object LoaderInfoImpl { - @JvmStatic - fun getVersion(): String = - FabricLoader.getInstance() - .getModContainer("lambda").orElseThrow() - .metadata.version.friendlyString -} diff --git a/quilt/src/main/kotlin/com/lambda/quilt/LambdaQuilt.kt b/quilt/src/main/kotlin/com/lambda/quilt/LambdaQuilt.kt deleted file mode 100644 index 7c4beaf68..000000000 --- a/quilt/src/main/kotlin/com/lambda/quilt/LambdaQuilt.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.lambda.quilt - -import com.lambda.Lambda -import com.lambda.Lambda.LOG -import com.lambda.Lambda.MOD_NAME -import com.lambda.Lambda.VERSION -import org.quiltmc.loader.api.ModContainer -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer - -// Cannot use `object` because Quilt has a class fetish (object is a class in Kotlin with a private constructor) -class LambdaQuilt : ModInitializer { - // If the mod is marked as non nullable, Quilt will panic because it can't find the instrisic library - override fun onInitialize(mod: ModContainer?) { - Lambda.initialize() - LOG.info("$MOD_NAME Quilt $VERSION initialized.") - } -} diff --git a/quilt/src/main/kotlin/com/lambda/quilt/LoaderInfoImpl.kt b/quilt/src/main/kotlin/com/lambda/quilt/LoaderInfoImpl.kt deleted file mode 100644 index 82e10a526..000000000 --- a/quilt/src/main/kotlin/com/lambda/quilt/LoaderInfoImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.lambda.quilt - -import org.quiltmc.loader.api.QuiltLoader - - -object LoaderInfoImpl { - @JvmStatic - fun getVersion(): String = - QuiltLoader - .getModContainer("lambda").orElseThrow() - .metadata().version().raw() -} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index c274eb0ec..000000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "schema_version": 1, - "mixin": [ - "lambda.mixins.common.json" - ], - "quilt_loader": { - "group": "${group}", - "id": "${mod_id}", - "version": "${mod_version}", - "metadata": { - "name": "Lambda", - "description": "${mod_description}", - "contributors": { - "Constructor": "Owner" - }, - "contact": { - "sources": "https://github.com/lambda-client/lambda" - }, - "icon": "assets/lambda/lambda.png" - }, - "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": [ - "com.lambda.quilt.LambdaQuilt" - ] - }, - "depends": [ - { - "id": "quilt_loader", - "version": "*" - }, - { - "id": "quilt_base", - "version": "*" - }, - { - "id": "qkl", - "version": ">=3.0.0" - }, - { - "id": "minecraft", - "version": ">=1.20.1" - }, - { - "id": "architectury", - "version": ">=9.1.12" - } - ] - }, - "minecraft": { - "environment": "*" - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index b3e612ff9..dd52d83ef 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,4 +13,4 @@ include("common") include("fabric") include("forge") include("neoforge") -include("quilt") +//include("quilt") From 3c7ca37e1d44182ff13f92877c6d455adb68f262 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:24:24 -0400 Subject: [PATCH 3/7] Fix: Reflections (doesn't work everywhere) please end my suffering that is of multiplatform minecraft mod --- common/src/main/kotlin/com/lambda/Loader.kt | 2 +- .../com/lambda/command/CommandManager.kt | 14 ++++++++++++-- .../kotlin/com/lambda/module/ModuleRegistry.kt | 18 +++++++++++++++--- fabric/build.gradle.kts | 2 +- forge/build.gradle.kts | 6 +++--- forge/src/main/resources/META-INF/mods.toml | 4 ++-- neoforge/build.gradle.kts | 14 ++++++++++++-- neoforge/src/main/resources/META-INF/mods.toml | 4 ++-- 8 files changed, 48 insertions(+), 16 deletions(-) diff --git a/common/src/main/kotlin/com/lambda/Loader.kt b/common/src/main/kotlin/com/lambda/Loader.kt index fb804ca99..58c853e91 100644 --- a/common/src/main/kotlin/com/lambda/Loader.kt +++ b/common/src/main/kotlin/com/lambda/Loader.kt @@ -27,4 +27,4 @@ object Loader { LOG.info("${Lambda.MOD_NAME} ${Lambda.VERSION} was successfully initialized (${initTime}ms)") } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/command/CommandManager.kt b/common/src/main/kotlin/com/lambda/command/CommandManager.kt index 6c8fd8233..8afaa6fdc 100644 --- a/common/src/main/kotlin/com/lambda/command/CommandManager.kt +++ b/common/src/main/kotlin/com/lambda/command/CommandManager.kt @@ -116,7 +116,17 @@ object CommandManager : Configurable(LambdaConfig), Loadable { override fun load(): String { Reflections( ConfigurationBuilder() - .setUrls(ClasspathHelper.forPackage("com.lambda.command.commands")) + // Let's hope the maintainer of the library releases a new version soon + // because this is horrible, it takes multiple SECONDS to scan the classpath, + // and it's not even that big + // + // The culprit may be due to [ClasspathHelper.forClassLoader()] loading + // the classes from the main thread while we are in a different thread. + // If this is the case I wish the maintainer a very bad day. + .addUrls(ClasspathHelper.forJavaClassPath()) + .addUrls(ClasspathHelper.forClassLoader()) + .filterInputsBy { it.contains("lambda") } + .forPackage("com.lambda.module.modules") .setScanners(Scanners.SubTypes) ).getSubTypesOf(LambdaCommand::class.java).forEach { commandClass -> commandClass.declaredFields.find { @@ -131,4 +141,4 @@ object CommandManager : Configurable(LambdaConfig), Loadable { return "Registered ${commands.size} commands" } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt b/common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt index 5c8a66331..0b86e6d55 100644 --- a/common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt +++ b/common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt @@ -7,6 +7,8 @@ import org.reflections.scanners.Scanners import org.reflections.util.ClasspathHelper import org.reflections.util.ConfigurationBuilder + + /** * The [ModuleRegistry] object is responsible for managing all [Module] instances in the system. * @@ -21,8 +23,18 @@ object ModuleRegistry : Loadable { override fun load(): String { Reflections( ConfigurationBuilder() - .setUrls(ClasspathHelper.forPackage("com.lambda.module.modules")) - .setScanners(Scanners.SubTypes) + // Let's hope the maintainer of the library releases a new version soon + // because this is horrible, it takes multiple SECONDS to scan the classpath, + // and it's not even that big + // + // The culprit may be due to [ClasspathHelper.forClassLoader()] loading + // the classes from the main thread while we are in a different thread. + // If this is the case I wish the maintainer a very bad day. + .addUrls(ClasspathHelper.forJavaClassPath()) + .addUrls(ClasspathHelper.forClassLoader()) + .filterInputsBy { it.contains("lambda") } + .forPackage("com.lambda.module.modules") + .addScanners(Scanners.SubTypes) ).getSubTypesOf(Module::class.java).forEach { moduleClass -> moduleClass.declaredFields.find { it.name == "INSTANCE" @@ -36,4 +48,4 @@ object ModuleRegistry : Loadable { return "Registered ${modules.size} modules with ${modules.sumOf { it.settings.size }} settings" } -} \ No newline at end of file +} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 29f91a36f..16dc314f8 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -51,7 +51,7 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") - includeLib("org.javassist:javassist:3.27.0-GA") + includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar // includeMod(...) diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 07c463587..2f6487722 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,5 +1,4 @@ val forgeVersion = property("forge_version").toString() -val kotlinVersion = property("kotlin_version").toString() val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() val mixinExtrasVersion = property("mixinextras_version").toString() @@ -58,10 +57,12 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { implementation(it) forgeRuntimeLibrary(it) + include(it) } shadowInclude.dependencies.forEach { implementation(it) + forgeRuntimeLibrary(it) shadowCommon(it) } } @@ -75,13 +76,12 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") - includeLib("org.javassist:javassist:3.30.0-GA") + includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar // includeMod(...) // Add Kotlin - shadowInclude("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") // MixinExtras diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index c975d8b86..de83e8760 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,7 +1,7 @@ modLoader = "javafml" loaderVersion = "[48,)" license = "GNU General Public License v3.0" -issueTrackerURL = "https://github.com/lambda-client/lambda/issues +issueTrackerURL = "https://github.com/lambda-client/lambda/issues" [[mods]] modId = "lambda" @@ -30,5 +30,5 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues modId = "architectury" mandatory = true versionRange = "[11.0.7,)" - ordering = "NONE" + ordering = "AFTER" side = "CLIENT" diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 079e02be8..367ef82dc 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -31,16 +31,19 @@ val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { implementation(it) + forgeRuntimeLibrary(it) include(it) } includeMod.dependencies.forEach { modImplementation(it) + forgeRuntimeLibrary(it) include(it) } shadowInclude.dependencies.forEach { implementation(it) + forgeRuntimeLibrary(it) shadowCommon(it) } } @@ -54,13 +57,15 @@ dependencies { // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") - includeLib("org.javassist:javassist:3.30.0-GA") + includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar // includeMod(...) // Add Kotlin - shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") + shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") { + exclude("org.jetbrains", "annotations") + } // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } @@ -84,6 +89,11 @@ tasks { } } + shadowJar { + relocate("kotlin", "com.lambda.kotlin") + relocate("kotlinx", "com.lambda.kotlinx") + } + remapJar { atAccessWideners.add("lambda.accesswidener") } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index 41a6b83bc..4be8c5ceb 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -1,7 +1,7 @@ modLoader = "javafml" loaderVersion = "[2,)" license = "GNU General Public License v3.0" -issueTrackerURL = "https://github.com/lambda-client/lambda/issues +issueTrackerURL = "https://github.com/lambda-client/lambda/issues" #updateJSONURL = "https://raw.githubusercontent.com/lambda-client/lambda/main/update.json" [[mods]] @@ -34,7 +34,7 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues mandatory = true type = "required" versionRange = "[11.0.7,)" - ordering = "NONE" + ordering = "AFTER" side = "CLIENT" [[mixins]] From 2440e72e08c36a9ffe4d7494e0a746b8b586a6e5 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sat, 23 Mar 2024 23:04:08 +0100 Subject: [PATCH 4/7] Fix command discovery --- common/src/main/kotlin/com/lambda/command/CommandManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/com/lambda/command/CommandManager.kt b/common/src/main/kotlin/com/lambda/command/CommandManager.kt index 8afaa6fdc..9722ddf7a 100644 --- a/common/src/main/kotlin/com/lambda/command/CommandManager.kt +++ b/common/src/main/kotlin/com/lambda/command/CommandManager.kt @@ -126,7 +126,7 @@ object CommandManager : Configurable(LambdaConfig), Loadable { .addUrls(ClasspathHelper.forJavaClassPath()) .addUrls(ClasspathHelper.forClassLoader()) .filterInputsBy { it.contains("lambda") } - .forPackage("com.lambda.module.modules") + .forPackage("com.lambda.command.commands") .setScanners(Scanners.SubTypes) ).getSubTypesOf(LambdaCommand::class.java).forEach { commandClass -> commandClass.declaredFields.find { From 9f728a1cccb17c175aef2f256132f31ed1b209d7 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sat, 23 Mar 2024 19:19:25 -0400 Subject: [PATCH 5/7] Added the kotlin modloader back --- common/build.gradle.kts | 3 -- common/src/main/kotlin/com/lambda/Lambda.kt | 7 ++--- .../kotlin/com/lambda/util/FolderRegister.kt | 4 +-- fabric/build.gradle.kts | 18 ++---------- fabric/src/main/resources/fabric.mod.json | 3 +- forge/build.gradle.kts | 25 +++++----------- .../kotlin/com/lambda/forge/LambdaForge.kt | 2 +- forge/src/main/resources/META-INF/mods.toml | 10 +++---- gradle.properties | 2 ++ neoforge/build.gradle.kts | 29 +++---------------- .../com/lambda/neoforge/LambdaNeoForge.kt | 2 +- .../src/main/resources/META-INF/mods.toml | 10 +++---- 12 files changed, 34 insertions(+), 81 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index df63ada30..256c15a52 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -20,9 +20,6 @@ dependencies { // Do NOT use other classes from fabric loader modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") - // Remove the following line if you don't want to depend on the API - modApi("dev.architectury:architectury:$architecturyVersion") - // Add dependencies on the required Kotlin modules. implementation("org.reflections:reflections:0.10.2") diff --git a/common/src/main/kotlin/com/lambda/Lambda.kt b/common/src/main/kotlin/com/lambda/Lambda.kt index c91ab68f1..a1b1cb6d6 100644 --- a/common/src/main/kotlin/com/lambda/Lambda.kt +++ b/common/src/main/kotlin/com/lambda/Lambda.kt @@ -5,13 +5,11 @@ import com.google.gson.GsonBuilder import com.lambda.config.serializer.BlockPosSerializer import com.lambda.config.serializer.BlockSerializer import com.lambda.config.serializer.ColorSerializer -import dev.architectury.platform.Platform import net.minecraft.block.Block import net.minecraft.client.MinecraftClient import net.minecraft.util.math.BlockPos -import org.apache.logging.log4j.Level import org.apache.logging.log4j.LogManager -import org.apache.logging.log4j.core.Logger +import org.apache.logging.log4j.Logger import java.awt.Color @@ -20,8 +18,7 @@ object Lambda { const val MOD_ID = "lambda" const val SYMBOL = "λ" val VERSION: String = LoaderInfo.getVersion() - val LOG = (LogManager.getLogger(SYMBOL) as Logger) - .apply { level = if (Platform.isDevelopmentEnvironment()) Level.DEBUG else Level.INFO } + val LOG: Logger = LogManager.getLogger(SYMBOL) val mc: MinecraftClient by lazy { MinecraftClient.getInstance() } val gson: Gson = GsonBuilder() diff --git a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt index 4960a3508..e57267aa4 100644 --- a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt +++ b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt @@ -1,9 +1,9 @@ package com.lambda.util +import com.lambda.Lambda.mc import com.lambda.util.FolderRegister.config import com.lambda.util.FolderRegister.lambda import com.lambda.util.FolderRegister.minecraft -import dev.architectury.platform.Platform import java.io.File /** @@ -14,7 +14,7 @@ import java.io.File * @property config The directory for storing configuration files, located within the Lambda directory. */ object FolderRegister { - val minecraft: File = Platform.getGameFolder().toFile() + val minecraft: File = mc.runDirectory val lambda: File = File(minecraft, "lambda") val config: File = File(lambda, "config") } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 16dc314f8..3729ad738 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,8 +1,7 @@ val fabricLoaderVersion = property("fabric_loader_version").toString() val fabricApiVersion = property("fabric_api_version").toString() -val kotlinVersion = property("kotlin_version").toString() -val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() +val kotlinFabricVersion = property("kotlin_fabric_version").toString() architectury { platformSetupLoomIde() @@ -24,7 +23,6 @@ val common: Configuration by configurations.creating { val includeLib: Configuration by configurations.creating val includeMod: Configuration by configurations.creating -val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { @@ -34,11 +32,7 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { modImplementation(it) - } - - shadowInclude.dependencies.forEach { - implementation(it) - shadowCommon(it) + include(it) } } @@ -46,18 +40,12 @@ dependencies { // Fabric API (Do not touch) modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") - // Remove the following line if you don't want to depend on the API - modApi("dev.architectury:architectury-fabric:$architecturyVersion") - // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar - // includeMod(...) - - // Add Kotlin - shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") + includeMod("net.fabricmc:fabric-language-kotlin:$kotlinFabricVersion") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 04047de73..b3e610ce0 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -17,6 +17,7 @@ "entrypoints": { "client": [ { + "adapter": "kotlin", "value": "com.lambda.fabric.LambdaFabric" } ] @@ -27,8 +28,8 @@ "depends": { "fabricloader": ">=0.15.1", "fabric-api": ">=0.91.3+1.20.4", - "architectury": ">=11.0.8", "minecraft": "1.20.4", + "fabric-language-kotlin": ">=${kotlin_fabric_version}", "java": ">=17" } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 2f6487722..6ab56961a 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,7 +1,7 @@ val forgeVersion = property("forge_version").toString() -val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() val mixinExtrasVersion = property("mixinextras_version").toString() +val kotlinForgeVersion = property("kotlin_forge_version").toString() architectury { platformSetupLoomIde() @@ -34,6 +34,7 @@ loom { repositories { maven("https://cursemaven.com") + maven("https://thedarkcolour.github.io/KotlinForForge/") } val common: Configuration by configurations.creating { @@ -48,46 +49,34 @@ val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { - implementation(it) + forgeRuntimeLibrary(it) include(it) } - // Please look at this before yelling at me - // https://docs.architectury.dev/loom/using_libraries/ includeMod.dependencies.forEach { - implementation(it) forgeRuntimeLibrary(it) include(it) } - - shadowInclude.dependencies.forEach { - implementation(it) - forgeRuntimeLibrary(it) - shadowCommon(it) - } } dependencies { // Forge API forge("net.minecraftforge:forge:$forgeVersion") - // Remove the following line if you don't want to depend on the API - modApi("dev.architectury:architectury-forge:$architecturyVersion") - // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar - // includeMod(...) - - // Add Kotlin - shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") + includeMod("thedarkcolour:kotlinforforge:$kotlinForgeVersion") // MixinExtras implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) + // Fix KFF + compileOnly(kotlin("stdlib")) + // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } diff --git a/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt b/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt index c279f6a82..4ba6b9ec0 100644 --- a/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt +++ b/forge/src/main/kotlin/com/lambda/forge/LambdaForge.kt @@ -8,7 +8,7 @@ import net.minecraftforge.fml.common.Mod @Mod(Lambda.MOD_ID) -class LambdaForge { +object LambdaForge { init { Lambda.initialize() LOG.info("$MOD_NAME Forge $VERSION initialized.") diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index de83e8760..c91f2943b 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ -modLoader = "javafml" -loaderVersion = "[48,)" +modLoader = "kotlinforforge" +loaderVersion = "[4.10,)" license = "GNU General Public License v3.0" issueTrackerURL = "https://github.com/lambda-client/lambda/issues" @@ -27,8 +27,8 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues" side = "CLIENT" [[dependencies.lambda]] - modId = "architectury" + modId = "kotlinforforge" mandatory = true - versionRange = "[11.0.7,)" - ordering = "AFTER" + versionRange = "[4.10,)" + ordering = "NONE" side = "CLIENT" diff --git a/gradle.properties b/gradle.properties index 84648d54c..cc7adc17a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,9 +19,11 @@ architectury_version=11.1.13 fabric_loader_version=0.15.7 yarn_mappings=1.20.4+build.3 fabric_api_version=0.96.4+1.20.4 +kotlin_fabric_version=1.10.19+kotlin.1.9.23 # Forge https://files.minecraftforge.net/ forge_version=1.20.4-49.0.31 +kotlin_forge_version=4.10.0 # NeoForge https://neoforged.net neo_version=20.4.196 diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 367ef82dc..091da7074 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,7 +1,6 @@ val neoVersion = property("neo_version").toString() -val kotlinxCoroutinesVersion = property("kotlinx_coroutines_version").toString() val architecturyVersion = property("architectury_version").toString() -val mixinExtrasVersion = property("mixinextras_version").toString() +val kotlinForgeVersion = property("kotlin_forge_version").toString() architectury { platformSetupLoomIde() @@ -16,6 +15,7 @@ loom { repositories { maven("https://maven.neoforged.net/releases/") + maven("https://thedarkcolour.github.io/KotlinForForge/") } val common: Configuration by configurations.creating { @@ -26,7 +26,6 @@ val common: Configuration by configurations.creating { val includeLib: Configuration by configurations.creating val includeMod: Configuration by configurations.creating -val shadowInclude: Configuration by configurations.creating fun DependencyHandlerScope.setupConfigurations() { includeLib.dependencies.forEach { @@ -36,15 +35,8 @@ fun DependencyHandlerScope.setupConfigurations() { } includeMod.dependencies.forEach { - modImplementation(it) - forgeRuntimeLibrary(it) - include(it) - } - - shadowInclude.dependencies.forEach { implementation(it) - forgeRuntimeLibrary(it) - shadowCommon(it) + include(it) } } @@ -52,20 +44,12 @@ dependencies { // NeoForge API neoForge("net.neoforged:neoforge:$neoVersion") - // Remove the following line if you don't want to depend on the API - modApi("dev.architectury:architectury-neoforge:$architecturyVersion") - // Add dependencies on the required Kotlin modules. includeLib("org.reflections:reflections:0.10.2") includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar - // includeMod(...) - - // Add Kotlin - shadowInclude("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") { - exclude("org.jetbrains", "annotations") - } + includeMod("thedarkcolour:kotlinforforge-neoforge:$kotlinForgeVersion") // Common (Do not touch) common(project(":common", configuration = "namedElements")) { isTransitive = false } @@ -89,11 +73,6 @@ tasks { } } - shadowJar { - relocate("kotlin", "com.lambda.kotlin") - relocate("kotlinx", "com.lambda.kotlinx") - } - remapJar { atAccessWideners.add("lambda.accesswidener") } diff --git a/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt b/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt index 805c126e3..971f595b8 100644 --- a/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt +++ b/neoforge/src/main/kotlin/com/lambda/neoforge/LambdaNeoForge.kt @@ -7,7 +7,7 @@ import com.lambda.Lambda.MOD_NAME import com.lambda.Lambda.VERSION @Mod(Lambda.MOD_ID) -class LambdaNeoForge { +object LambdaNeoForge { init { Lambda.initialize() LOG.info("$MOD_NAME NeoForge $VERSION initialized.") diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index 4be8c5ceb..7692b9249 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ -modLoader = "javafml" -loaderVersion = "[2,)" +modLoader = "kotlinforforge" +loaderVersion = "[4.10,)" license = "GNU General Public License v3.0" issueTrackerURL = "https://github.com/lambda-client/lambda/issues" #updateJSONURL = "https://raw.githubusercontent.com/lambda-client/lambda/main/update.json" @@ -30,11 +30,11 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues" side = "CLIENT" [[dependencies.lambda]] - modId = "architectury" + modId = "kotlinforforge" mandatory = true type = "required" - versionRange = "[11.0.7,)" - ordering = "AFTER" + versionRange = "[4.10,)" + ordering = "NONE" side = "CLIENT" [[mixins]] From 436d42d48aad6ebcbd015610f7633afb16c1a17c Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sat, 23 Mar 2024 19:59:09 -0400 Subject: [PATCH 6/7] Fix: Forge and Fabric yay --- fabric/build.gradle.kts | 1 + .../kotlin/com/lambda/fabric/LambdaFabric.kt | 2 +- forge/build.gradle.kts | 18 ++++++------------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 3729ad738..d5f3e092c 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -45,6 +45,7 @@ dependencies { includeLib("org.javassist:javassist:3.28.0-GA") // Add mods to the mod jar + includeMod("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion") includeMod("net.fabricmc:fabric-language-kotlin:$kotlinFabricVersion") // Common (Do not touch) diff --git a/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt b/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt index a3ce3cd12..1b6840aa8 100644 --- a/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt +++ b/fabric/src/main/kotlin/com/lambda/fabric/LambdaFabric.kt @@ -6,7 +6,7 @@ import com.lambda.Lambda.LOG import com.lambda.Lambda.MOD_NAME import com.lambda.Lambda.VERSION -class LambdaFabric : ClientModInitializer { +object LambdaFabric : ClientModInitializer { override fun onInitializeClient() { Lambda.initialize() LOG.info("$MOD_NAME Fabric $VERSION initialized.") diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 6ab56961a..6bfa37c09 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -18,18 +18,6 @@ loom { extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name) mixinConfig("lambda.mixins.common.json") } - - mods { - register("forge") { - sourceSet("main", project(":forge")) - - sourceSets.forEach { - val dir = layout.buildDirectory.dir("sourcesSets/${it.name}") - it.output.setResourcesDir(dir) - it.java.destinationDirectory.set(dir) - } - } - } } repositories { @@ -98,4 +86,10 @@ tasks { )) } } + + sourceSets.forEach { + val dir = layout.buildDirectory.dir("sourcesSets/${it.name}") + it.output.setResourcesDir(dir) + it.java.destinationDirectory.set(dir) + } } From c5f13a40de4ed0bbf3505fecc428fcb6d553bf3c Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sat, 23 Mar 2024 20:23:00 -0400 Subject: [PATCH 7/7] Test: NeoForge --- neoforge/build.gradle.kts | 11 +++++++++++ neoforge/src/main/resources/META-INF/mods.toml | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 091da7074..a6e03804c 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -11,6 +11,9 @@ base.archivesName.set("${base.archivesName.get()}-neoforge") loom { accessWidenerPath.set(project(":common").loom.accessWidenerPath) + neoForge { + enableTransitiveAccessWideners = true + } } repositories { @@ -36,6 +39,7 @@ fun DependencyHandlerScope.setupConfigurations() { includeMod.dependencies.forEach { implementation(it) + forgeRuntimeLibrary(it) include(it) } } @@ -75,5 +79,12 @@ tasks { remapJar { atAccessWideners.add("lambda.accesswidener") + injectAccessWidener.set(true) + } + + sourceSets.forEach { + val dir = layout.buildDirectory.dir("sourcesSets/${it.name}") + it.output.setResourcesDir(dir) + it.java.destinationDirectory.set(dir) } } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index 7692b9249..b751bb188 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -13,6 +13,9 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues" logoFile = "assets/lambda/lambda.png" displayTest = "IGNORE_ALL_VERSION" +[[mixins]] + config = "lambda.mixins.common.json" + [[dependencies.lambda]] modId = "neoforge" mandatory = true @@ -36,7 +39,3 @@ issueTrackerURL = "https://github.com/lambda-client/lambda/issues" versionRange = "[4.10,)" ordering = "NONE" side = "CLIENT" - -[[mixins]] - config = "lambda.mixins.common.json" - environment = "client"