From 31f6a817a29e1617daac60c33af12cc3231e9894 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 29 Jan 2024 16:04:11 -0500 Subject: [PATCH 1/8] kotlin kotlin kotlin kotlin kotlin kotlin kotlin kotlin --- build.gradle | 108 -------- build.gradle.kts | 109 ++++++++ common/build.gradle | 112 --------- common/build.gradle.kts | 118 +++++++++ fabric/build.gradle | 300 ----------------------- fabric/build.gradle.kts | 298 ++++++++++++++++++++++ forge/{build.gradle => build.gradle.kts} | 73 +++--- settings.gradle | 15 -- settings.gradle.kts | 15 ++ 9 files changed, 580 insertions(+), 568 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 common/build.gradle create mode 100644 common/build.gradle.kts delete mode 100644 fabric/build.gradle create mode 100644 fabric/build.gradle.kts rename forge/{build.gradle => build.gradle.kts} (77%) delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 5b8ba3f9f..000000000 --- a/build.gradle +++ /dev/null @@ -1,108 +0,0 @@ -import dev.ithundxr.silk.ChangelogText - -plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.4.+" apply false - id "me.modmuss50.mod-publish-plugin" version "0.3.4" apply false // https://github.com/modmuss50/mod-publish-plugin - id "dev.ithundxr.silk" version "0.11.15" // https://github.com/IThundxr/silk -} - -architectury { - minecraft = minecraft_version -} - -subprojects { - apply plugin: "dev.architectury.loom" - - loom { - silentMojangMappingsLicense() - runs.configureEach { - vmArg("-Dmixin.debug.export=true") - vmArg("-Dmixin.env.remapRefMap=true") - vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg") - } - } - - repositories { - mavenCentral() - maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI - maven { url = "https://maven.blamejared.com/" } // JEI, Hex Casting - maven { url = "https://maven.parchmentmc.org" } // Parchment mappings - maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings - maven { url = "https://jm.gserv.me/repository/maven-public/" } // JourneyMap API - maven { url = "https://api.modrinth.com/maven" } // LazyDFU, JourneyMap - maven { // Flywheel - url = "https://maven.tterrag.com/" - content { - // need to be specific here due to version overlaps - includeGroup("com.jozufozu.flywheel") - } - } - maven { // Extended Bogeys - url = "https://maven.ithundxr.dev/private" - content { includeGroup("com.rabbitminers") } - credentials { - if (System.getenv("GITHUB_RUN_NUMBER")) { - username = "railways-github" - password = System.getenv("MAVEN_TOKEN") - } else { - username = findProperty("IThundxrMavenUsername") - password = findProperty("IThundxrMavenPassword") - } - } - } - maven { url = 'https://maven.maxhenkel.de/repository/public' } // Simple Voice Chat - } - - dependencies { - minecraft "com.mojang:minecraft:${minecraft_version}" - // layered mappings - Mojmap names, parchment and QM docs and parameters - mappings(loom.layered { - it.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${qm_version}:intermediary-v2") - it.parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip") - it.officialMojangMappings { nameSyntheticMembers = false } - }) - - // see each subproject for dependencies. - } - - tasks.register("moveBuiltJars", Copy) { - if (project.path != ":common") { - def remapJar = project.tasks.named('remapJar') - dependsOn remapJar - from remapJar - } - - into(rootProject.file("jars")) - } -} - -allprojects { - - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" - - archivesBaseName = archives_base_name - group = maven_group - - // Formats the mod version to include the loader, Minecraft version, and build number (if present) - // example: 1.0.0+fabric-1.19.2-build.100 (or -local) - String isRelease = System.getenv("RELEASE_BUILD") - String buildNumber = System.getenv("GITHUB_RUN_NUMBER") - String build = buildNumber ? "build.${buildNumber}" : "local" - - version = "$mod_version+$project.name-mc$minecraft_version" + (isRelease ? "" : "-$build") - - tasks.withType(JavaCompile).configureEach { - options.encoding = "UTF-8" - } - - java { - withSourcesJar() - } -} - -String getChangelogText() { - return ChangelogText.getChangelogText(project) -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..a6f0f3e50 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,109 @@ +import net.fabricmc.loom.api.LoomGradleExtensionAPI + +plugins { + java + id("architectury-plugin") version "3.4-SNAPSHOT" + id("dev.architectury.loom") version "1.4.+" apply false + id("me.modmuss50.mod-publish-plugin") version "0.3.4" apply false // https://github.com/modmuss50/mod-publish-plugin + id("dev.ithundxr.silk") version "0.11.15" // https://github.com/IThundxr/silk +} + +architectury { + minecraft = "minecraft_version"() +} + +subprojects { + apply(plugin = "dev.architectury.loom") + + repositories { + mavenCentral() + maven { url = uri("https://maven.shedaniel.me/") } // Cloth Config, REI + maven { url = uri("https://maven.blamejared.com/") } // JEI, Hex Casting + maven { url = uri("https://maven.parchmentmc.org") } // Parchment mappings + maven { url = uri("https://maven.quiltmc.org/repository/release") } // Quilt Mappings + maven { url = uri("https://jm.gserv.me/repository/maven-public/") } // JourneyMap API + maven { url = uri("https://api.modrinth.com/maven") } // LazyDFU, JourneyMap + maven { // Flywheel + url = uri("https://maven.tterrag.com/") + content { + // need to be specific here due to version overlaps + includeGroup("com.jozufozu.flywheel") + } + } + maven { // Extended Bogeys + url = uri("https://maven.ithundxr.dev/private") + content { includeGroup("com.rabbitminers") } + credentials { + if (System.getenv("GITHUB_RUN_NUMBER") != null) { + username = "railways-github" + password = System.getenv("MAVEN_TOKEN") + } else { + username = findProperty("IThundxrMavenUsername").toString() + password = findProperty("IThundxrMavenPassword").toString() + } + } + } + maven { url = uri("https://maven.maxhenkel.de/repository/public") } // Simple Voice Chat + } + + val loom = project.extensions.getByName("loom") + +// loom { +// silentMojangMappingsLicense() +// runs.configureEach { +// vmArg("-Dmixin.debug.export=true") +// vmArg("-Dmixin.env.remapRefMap=true") +// vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg") +// } +// } + + dependencies { + "minecraft"("com.mojang:minecraft:${"minecraft_version"()}") + // layered mappings - Mojmap names, parchment and QM docs and parameters + "mappings"(loom.layered { + mappings("org.quiltmc:quilt-mappings:${"minecraft_version"()}+build.${"qm_version"()}:intermediary-v2") + parchment("org.parchmentmc.data:parchment-${"minecraft_version"()}:${"parchment_version"()}@zip") + officialMojangMappings { nameSyntheticMembers = false } + }) + } + + tasks.register("moveBuiltJars") { + if (project.path != ":common") { + val remapJar by project.tasks.named("remapJar") + dependsOn(remapJar) + from(remapJar) + } + + into(rootProject.file("jars")) + } +} + +allprojects { + apply(plugin = "java") + apply(plugin = "architectury-plugin") + apply(plugin = "maven-publish") + + base.archivesName.set("archives_base_name"()) + group = "maven_group"() + + // Formats the mod version to include the loader, Minecraft version, and build number (if present) + // example: 1.0.0+fabric-1.19.2-build.100 (or -local) + val isRelease: Boolean = System.getenv("RELEASE_BUILD")?.toBoolean() == true + val buildNumber = System.getenv("GITHUB_RUN_NUMBER") + val build = if (buildNumber != null) "build.${buildNumber}" else "local" + + version = "${"mod_version"()}+${project.name}-mc${"minecraft_version"()}" + ( if (isRelease) "" else "-${build}") + + tasks.withType().configureEach { + options.encoding = "UTF-8" + } + + java { + withSourcesJar() + } +} + +operator fun String.invoke(): String { + return rootProject.ext[this] as? String + ?: throw IllegalStateException("Property $this is not defined") +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index e08fc8224..000000000 --- a/common/build.gradle +++ /dev/null @@ -1,112 +0,0 @@ -import groovy.json.JsonOutput -import groovy.json.JsonSlurper - -loom { - accessWidenerPath = file("src/main/resources/railways.accesswidener") -} - -repositories { - // mavens for Create Fabric and dependencies - maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Journyemap - maven { url = "https://maven.terraformersmc.com/releases/" } // Mod Menu - maven { url = "https://mvn.devos.one/snapshots/" } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric - maven { url = "https://cursemaven.com" } // Forge Config API Port - maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API - maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes - maven { url = "https://jitpack.io/" } // Mixin Extras, Fabric ASM - maven { url = "https://maven.blamejared.com/" } // JEI, Hex Casting -} - -dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation("net.fabricmc:fabric-loader:${fabric_loader_version}") - // Compile against Create Fabric in common - // beware of differences across platforms! - // dependencies must also be pulled in to minimize problems, from remapping issues to compile errors. - // All dependencies except Flywheel and Registrate are NOT safe to use! - // Flywheel and Registrate must also be used carefully due to differences. - modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") - - // required for proper remapping and compiling - modCompileOnly("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") - - // JourneyMap compat - modCompileOnly("info.journeymap:journeymap-api:${journeymap_api_version}-fabric-SNAPSHOT") - - modCompileOnly "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}" - modCompileOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}" - modCompileOnly "curse.maven:malilib-303119:${malilib_version}" - modCompileOnly "curse.maven:tweakeroo-297344:${tweakeroo_version}" - modCompileOnly "maven.modrinth:sodium:${sodium_version}" - - // mod compat for tracks - - // Hex Casting -/* modCompileOnly("at.petra-k.paucal:paucal-common-${minecraft_version}:${paucal_version}") - modCompileOnly("at.petra-k.hexcasting:hexcasting-common-${minecraft_version}:${hexcasting_version}") - modCompileOnly("vazkii.patchouli:Patchouli-xplat:${minecraft_version}-${patchouli_version}")*/ - - if (enable_eb.toBoolean()) - modImplementation("com.rabbitminers:extendedbogeys-common:${EB_verison}+common-patch-") - - implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixin_extras_version}")) -} - -architectury { - common(enabled_platforms.split(",")) -} - -processResources { - // must be part of primary mod to be findable - exclude("resourcepacks/") - - // dont add development or to-do files into built jar - exclude("**/*.bbmodel", "**/*.lnk", "**/*.xcf", "**/*.md", "**/*.txt", "**/*.blend", "**/*.blend1", "**/PlatformMethods.class") - - // Minify all .json files in built jars - doLast { - fileTree(dir: processResources.outputs.files.asPath, include: '**/*.json').each { - it.text = JsonOutput.toJson(new JsonSlurper().parse(it)) - } - } -} - -sourceSets.main { - resources { // include generated resources in resources - srcDir("src/generated/resources") - exclude(".cache/**") - exclude("assets/create/**") - } -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = "${archives_base_name}-${project.name}-${minecraft_version}" - from components.java - } - } - - repositories { - if (System.getenv("MAVEN_TOKEN")) { - if (System.getenv("RELEASE_BUILD")) { - maven { - url "https://maven.ithundxr.dev/releases" - credentials { - username = "railways-github" - password = System.getenv("MAVEN_TOKEN") - } - } - } else { - maven { - url "https://maven.ithundxr.dev/snapshots" - credentials { - username = "railways-github" - password = System.getenv("MAVEN_TOKEN") - } - } - } - } - } -} \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts new file mode 100644 index 000000000..3564dab79 --- /dev/null +++ b/common/build.gradle.kts @@ -0,0 +1,118 @@ +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +loom { + accessWidenerPath = file("src/main/resources/railways.accesswidener") +} + +repositories { + // mavens for Create Fabric and dependencies + maven { url = uri("https://api.modrinth.com/maven") } // LazyDFU, Journyemap + maven { url = uri("https://maven.terraformersmc.com/releases/") } // Mod Menu + maven { url = uri("https://mvn.devos.one/snapshots/") } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric + maven { url = uri("https://cursemaven.com") } // Forge Config API Port + maven { url = uri("https://maven.cafeteria.dev/releases") } // Fake Player API + maven { url = uri("https://maven.jamieswhiteshirt.com/libs-release") } // Reach Entity Attributes + maven { url = uri("https://jitpack.io/") } // Mixin Extras, Fabric ASM + maven { url = uri("https://maven.blamejared.com/") } // JEI, Hex Casting +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader + modImplementation("net.fabricmc:fabric-loader:${"fabric_loader_version"()}") + // Compile against Create Fabric in common + // beware of differences across platforms! + // dependencies must also be pulled in to minimize problems, from remapping issues to compile errors. + // All dependencies except Flywheel and Registrate are NOT safe to use! + // Flywheel and Registrate must also be used carefully due to differences. + modCompileOnly("com.simibubi.create:create-fabric-${"minecraft_version"()}:${"create_fabric_version"()}") + + // required for proper remapping and compiling + modCompileOnly("net.fabricmc.fabric-api:fabric-api:${"fabric_api_version"()}") + + // JourneyMap compat + modCompileOnly("info.journeymap:journeymap-api:${"journeymap_api_version"()}-fabric-SNAPSHOT") + + modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${"voicechat_api_version"()}") + modCompileOnly("maven.modrinth:simple-voice-chat:fabric-${"voicechat_version"()}") + modCompileOnly("curse.maven:malilib-303119:${"malilib_version"()}") + modCompileOnly("curse.maven:tweakeroo-297344:${"tweakeroo_version"()}") + modCompileOnly("maven.modrinth:sodium:${"sodium_version"()}") + + // mod compat for tracks + + // Hex Casting +/* modCompileOnly("at.petra-k.paucal:paucal-common-${minecraft_version}:${paucal_version}") + modCompileOnly("at.petra-k.hexcasting:hexcasting-common-${minecraft_version}:${hexcasting_version}") + modCompileOnly("vazkii.patchouli:Patchouli-xplat:${minecraft_version}-${patchouli_version}")*/ + + val mixinExtras = "io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}" + + annotationProcessor(mixinExtras) + implementation(mixinExtras) +} + +architectury { + common(rootProject.property("enabled_platforms").toString().split(",")) +} + +tasks.processResources { + // must be part of primary mod to be findable + exclude("resourcepacks/") + + // dont add development or to-do files into built jar + exclude("**/*.bbmodel", "**/*.lnk", "**/*.xcf", "**/*.md", "**/*.txt", "**/*.blend", "**/*.blend1", "**/PlatformMethods.class") + + // Minify all .json files in built jars + //fixme +// doLast { +// fileTree(dir = outputs.files.asPath, include = "**/*.json").forEach { file -> +// file.writeText(JsonOutput.toJson(JsonSlurper().parseText(file.readText()))) +// } +// } +} + +sourceSets.main { + resources { // include generated resources in resources + srcDir("src/generated/resources") + exclude(".cache/**") + exclude("assets/create/**") + } +} + +publishing { + publications { + create("mavenCommon") { + artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + from(components["java"]) + } + } + + repositories { + if (System.getenv("MAVEN_TOKEN") != null) { + if (System.getenv("RELEASE_BUILD")?.toBoolean() == true) { + maven { + url = uri("https://maven.ithundxr.dev/releases") + credentials { + username = "railways-github" + password = System.getenv("MAVEN_TOKEN") + } + } + } else { + maven { + url = uri("https://maven.ithundxr.dev/snapshots") + credentials { + username = "railways-github" + password = System.getenv("MAVEN_TOKEN") + } + } + } + } + } +} + +operator fun String.invoke(): String { + return rootProject.ext[this] as? String + ?: throw IllegalStateException("Property $this is not defined") +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle deleted file mode 100644 index fedeae22f..000000000 --- a/fabric/build.gradle +++ /dev/null @@ -1,300 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" - id "me.modmuss50.mod-publish-plugin" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -loom { - Project common = project(":common") - accessWidenerPath = common.loom.accessWidenerPath - - runs { - datagen { - client() - - name "Minecraft Data" - vmArg "-Dfabric-api.datagen" - vmArg "-Dfabric-api.datagen.output-dir=${common.file("src/generated/resources")}" - vmArg "-Dfabric-api.datagen.modid=railways" - vmArg "-Dporting_lib.datagen.existing_resources=${common.file("src/main/resources")}" - - environmentVariable("DATAGEN", "TRUE") - } - } -} - -configurations { - 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 - developmentFabric.extendsFrom common -} - -repositories { - // mavens for Fabric-exclusives - maven { url = "https://maven.terraformersmc.com/releases/" } // Mod Menu, EMI - maven { url = "https://mvn.devos.one/snapshots/" } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric - maven { url = "https://cursemaven.com" } // Forge Config API Port - maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API - maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes - maven { url = "https://jitpack.io/" } // Mixin Extras, Fabric ASM - maven { // forge config api port - name = "Fuzs Mod Resources" - url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" - } - maven { - url = "https://maven.blamejared.com/" - content { - includeGroup("at.petra-k") - includeGroup("vazkii.patchouli") - } - } // JEI, Hex Casting - maven { - name = 'Ladysnake Mods' - url = 'https://maven.ladysnake.org/releases' - content { - includeGroup("dev.onyxstudios.cardinal-components-api") - } - } // Cardinal Components (Hex Casting dependency) -} - -dependencies { - modImplementation("net.fabricmc:fabric-loader:${fabric_loader_version}") - common(project(path: ":common", configuration: "namedElements")) { transitive = false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive = false } - - // dependencies - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") - - // Create - dependencies are added transitively - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") - - // Fabric ASM (enum extension etc) - modImplementation("com.github.Chocohead:Fabric-ASM:v2.3") { - exclude (group: "net.fabricmc.fabric-api") - } - include "com.github.Chocohead:Fabric-ASM:v2.3" - - // Development QOL - modLocalRuntime("maven.modrinth:lazydfu:${lazydfu_version}") - modLocalRuntime("com.terraformersmc:modmenu:${modmenu_version}") - - // Recipe Viewers - Create Fabric supports JEI, REI, and EMI. - // See root gradle.properties to choose which to use at runtime. - switch (fabric_recipe_viewer.toLowerCase(Locale.ROOT)) { - case "jei": modLocalRuntime("mezz.jei:jei-${minecraft_version}-fabric:${jei_fabric_version}"); break - case "rei": modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}"); break - case "emi": modLocalRuntime("dev.emi:emi-fabric:${emi_version}"); break - case "disabled": break - default: println("Unknown recipe viewer specified: ${fabric_recipe_viewer}. Must be JEI, REI, EMI, or disabled.") - } - // if you would like to add integration with them, uncomment them here. -// modCompileOnly("mezz.jei:jei-${minecraft_version}-fabric:${jei_fabric_version}") -// modCompileOnly("mezz.jei:jei-${minecraft_version}-common:${jei_fabric_version}") -// modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${rei_version}") -// modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${rei_version}") -// modCompileOnly("dev.emi:emi:${emi_version}") - - modLocalRuntime("maven.modrinth:journeymap:${journeymap_version}-fabric") // Test with JourneyMap in dev - modLocalRuntime("info.journeymap:journeymap-api:${journeymap_api_version}-fabric-SNAPSHOT") // API is a JiJ on fabric, add manually - - modCompileOnly("info.journeymap:journeymap-api:${journeymap_api_version}-fabric-SNAPSHOT") // for some reason this is needed explicitly - - modCompileOnly "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}" - - if (enable_simple_voice_chat.toBoolean()) { - modLocalRuntime "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}" - } - - // because create fabric is a bit broken I think - modImplementation("net.minecraftforge:forgeconfigapiport-fabric:4.2.9") - - // mod compat for tracks - if (enable_hexcasting.toBoolean()) { - modLocalRuntime("at.petra-k.paucal:paucal-fabric-${minecraft_version}:${paucal_version}") - modLocalRuntime("at.petra-k.hexcasting:hexcasting-fabric-${minecraft_version}:${hexcasting_version}") - modLocalRuntime("vazkii.patchouli:Patchouli:${minecraft_version}-${patchouli_version}-FABRIC") - } - - if (enable_byg.toBoolean()) { - modLocalRuntime("maven.modrinth:biomesyougo:${byg_version}-fabric") - modLocalRuntime("maven.modrinth:terrablender:${terrablender_version_fabric}") - modLocalRuntime("maven.modrinth:geckolib:${geckolib_version_fabric}") - modLocalRuntime("maven.modrinth:corgilib:${corgilib_version_fabric}") - } - - if (enable_tweakeroo.toBoolean()) { - modLocalRuntime("curse.maven:tweakeroo-297344:${tweakeroo_version}") - modLocalRuntime("curse.maven:malilib-303119:${malilib_version}") - } - - if (enable_sodium_rubidium.toBoolean()) { - modLocalRuntime("maven.modrinth:sodium:${sodium_version}") - modLocalRuntime("org.joml:joml:1.10.2") - modLocalRuntime("maven.modrinth:indium:${indium_version}") - } - if (enable_iris.toBoolean()) { - modLocalRuntime("maven.modrinth:iris:${iris_version}") - } - - if (enable_eb.toBoolean()) { - modImplementation("com.rabbitminers:extendedbogeys-fabric:${EB_verison}+fabric") - } - - include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}"))) -} - -processResources { - // include packs - from(rootProject.file("common/src/main/resources")) { - include("resourcepacks/") - } - - // set up properties for filling into metadata - Map properties = Map.of( - "version", version as String, - "fabric_loader_version", fabric_loader_version, - "fabric_api_version", fabric_api_version, - "minecraft_version", minecraft_version, - "create_version", create_fabric_version, // on fabric, use the entire version, unlike forge - "voicechat_api_version", voicechat_api_version - ) - properties.forEach((k, v) -> inputs.property(k, v)) - - filesMatching("fabric.mod.json") { - expand properties - } -} - -def getGitHash = { -> - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'rev-parse', 'HEAD' - standardOutput = stdout - } - return stdout.toString().trim() -} - -def hasUnstaged = { -> - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'status', '--porcelain' - standardOutput = stdout - } - def result = stdout.toString().replaceAll("M gradlew", "").trim() - if (!result.isEmpty()) - println("Found stageable results:\n${result}\n") - return !result.isEmpty() -} - -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier = "dev-shadow" -} - -remapJar { - injectAccessWidener = true - inputFile.set shadowJar.archiveFile - dependsOn shadowJar - archiveClassifier = null -} - -jar { - archiveClassifier = "dev" - - String gitHash = "\"${getGitHash()}" + (hasUnstaged() ? "-modified" : "") + "\"" - - manifest { - attributes([ - "Git-Hash": gitHash - ]) - } -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } - - String gitHash = "\"${getGitHash()}" + (hasUnstaged() ? "-modified" : "") + "\"" - - manifest { - attributes([ - "Git-Hash": gitHash - ]) - } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishMods { - file = remapJar.archiveFile - version = project.version - changelog = getChangelogText() - type = STABLE - displayName = "Steam 'n' Rails $mod_version Fabric $minecraft_version" - modLoaders.add("fabric") - modLoaders.add("quilt") - - curseforge { - projectId = curseforge_id - accessToken = System.getenv("CURSEFORGE_TOKEN") - minecraftVersions.add(minecraft_version) - - requires { - slug = "create-fabric" - } - } - - modrinth { - projectId = modrinth_id - accessToken = System.getenv("MODRINTH_TOKEN") - minecraftVersions.add(minecraft_version) - - requires { - slug = "create-fabric" - } - } -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = "${archives_base_name}-${project.name}-${minecraft_version}" - from components.java - } - } - - repositories { - if (System.getenv("MAVEN_TOKEN")) { - if (System.getenv("RELEASE_BUILD")) { - maven { - url "https://maven.ithundxr.dev/releases" - credentials { - username = "railways-github" - password = System.getenv("MAVEN_TOKEN") - } - } - } else { - maven { - url "https://maven.ithundxr.dev/snapshots" - credentials { - username = "railways-github" - password = System.getenv("MAVEN_TOKEN") - } - } - } - } - } -} \ No newline at end of file diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts new file mode 100644 index 000000000..9ab81839b --- /dev/null +++ b/fabric/build.gradle.kts @@ -0,0 +1,298 @@ +import java.io.ByteArrayOutputStream + +plugins { + id("com.github.johnrengelman.shadow") version "7.1.2" + id("me.modmuss50.mod-publish-plugin") +} + +architectury { + platformSetupLoomIde() + fabric() +} + +loom { + val common = project(":common") + accessWidenerPath = common.loom.accessWidenerPath + + //fixme +// runs { +// datagen { +// client() +// +// name = "Minecraft Data" +// vmArg = "-Dfabric-api.datagen" +// vmArg = "-Dfabric-api.datagen.output-dir=${common.file("src/generated/resources")}" +// vmArg = "-Dfabric-api.datagen.modid=railways" +// vmArg = "-Dporting_lib.datagen.existing_resources=${common.file("src/main/resources")}" +// +// environmentVariable("DATAGEN", "TRUE") +// } +// } +} + +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating +val developmentFabric: Configuration by configurations.getting + +configurations { + compileOnly.configure { extendsFrom(common) } + runtimeOnly.configure { extendsFrom(common) } + developmentFabric.extendsFrom(common) +} + +repositories { + // mavens for Fabric-exclusives + maven { url = uri("https://maven.terraformersmc.com/releases/") } // Mod Menu, EMI + maven { url = uri("https://mvn.devos.one/snapshots/") } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric + maven { url = uri("https://cursemaven.com") } // Forge Config API Port + maven { url = uri("https://maven.cafeteria.dev/releases") } // Fake Player API + maven { url = uri("https://maven.jamieswhiteshirt.com/libs-release") } // Reach Entity Attributes + maven { url = uri("https://jitpack.io/") } // Mixin Extras, Fabric ASM + maven { // forge config api port + name = "Fuzs Mod Resources" + url = uri("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") + } + maven { + url = uri("https://maven.blamejared.com/") + content { + includeGroup("at.petra-k") + includeGroup("vazkii.patchouli") + } + } // JEI, Hex Casting + maven { + name = "Ladysnake Mods" + url = uri("https://maven.ladysnake.org/releases") + content { + includeGroup("dev.onyxstudios.cardinal-components-api") + } + } // Cardinal Components (Hex Casting dependency) +} + +dependencies { + modImplementation("net.fabricmc:fabric-loader:${"fabric_loader_version"()}") + common(project(":common", "namedElements")) { isTransitive = false } + shadowCommon(project(":common", "transformProductionFabric")) { isTransitive = false } + + // dependencies + modImplementation("net.fabricmc.fabric-api:fabric-api:${"fabric_api_version"()}") + + // Create - dependencies are added transitively + modImplementation("com.simibubi.create:create-fabric-${"minecraft_version"()}:${"create_fabric_version"()}") + + // Fabric ASM (enum extension etc) + modImplementation("com.github.Chocohead:Fabric-ASM:v2.3") { + exclude (group = "net.fabricmc.fabric-api") + } + + include("com.github.Chocohead:Fabric-ASM:v2.3") + + // Development QOL + modLocalRuntime("maven.modrinth:lazydfu:${"lazydfu_version"()}") + modLocalRuntime("com.terraformersmc:modmenu:${"modmenu_version"()}") + + modLocalRuntime("dev.emi:emi-fabric:${"emi_version"()}") + + modLocalRuntime("maven.modrinth:journeymap:${"journeymap_version"()}-fabric") // Test with JourneyMap in dev + modLocalRuntime("info.journeymap:journeymap-api:${"journeymap_api_version"()}-fabric-SNAPSHOT") // API is a JiJ on fabric, add manually + + modCompileOnly("info.journeymap:journeymap-api:${"journeymap_api_version"()}-fabric-SNAPSHOT") // for some reason this is needed explicitly + + modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${"voicechat_api_version"()}") + + if ("enable_simple_voice_chat"().toBoolean()) { + modLocalRuntime("maven.modrinth:simple-voice-chat:fabric-${"voicechat_version"()}") + } + + // because create fabric is a bit broken I think + modImplementation("net.minecraftforge:forgeconfigapiport-fabric:4.2.9") + + // mod compat for tracks + if ("enable_hexcasting"().toBoolean()) { + modLocalRuntime("at.petra-k.paucal:paucal-fabric-${"minecraft_version"()}:${"paucal_version"()}") + modLocalRuntime("at.petra-k.hexcasting:hexcasting-fabric-${"minecraft_version"()}:${"hexcasting_version"()}") + modLocalRuntime("vazkii.patchouli:Patchouli:${"minecraft_version"()}-${"patchouli_version"()}-FABRIC") + } + + if ("enable_byg"().toBoolean()) { + modLocalRuntime("maven.modrinth:biomesyougo:${"byg_version"()}-fabric") + modLocalRuntime("maven.modrinth:terrablender:${"terrablender_version_fabric"()}") + modLocalRuntime("maven.modrinth:geckolib:${"geckolib_version_fabric"()}") + modLocalRuntime("maven.modrinth:corgilib:${"corgilib_version_fabric"()}") + } + + if ("enable_tweakeroo"().toBoolean()) { + modLocalRuntime("curse.maven:tweakeroo-297344:${"tweakeroo_version"()}") + modLocalRuntime("curse.maven:malilib-303119:${"malilib_version"()}") + } + + if ("enable_sodium_rubidium"().toBoolean()) { + modLocalRuntime("maven.modrinth:sodium:${"sodium_version"()}") + modLocalRuntime("org.joml:joml:1.10.2") + modLocalRuntime("maven.modrinth:indium:${"indium_version"()}") + } + if ("enable_iris"().toBoolean()) { + modLocalRuntime("maven.modrinth:iris:${"iris_version"()}") + } + + if ("enable_eb"().toBoolean()) { + modImplementation("com.rabbitminers:extendedbogeys-fabric:${"EB_verison"()}+fabric") + } + + val mixinExtras = "io.github.llamalad7:mixinextras-fabric:${"mixin_extras_version"()}" + + annotationProcessor(mixinExtras) + implementation(mixinExtras) + include(mixinExtras) +} + +tasks.processResources { + // include packs + from(rootProject.file("common/src/main/resources")) { + include("resourcepacks/") + } + + // set up properties for filling into metadata + val properties = mapOf( + "version" to version as String, + "fabric_loader_version" to "fabric_loader_version"(), + "fabric_api_version" to "fabric_api_version"(), + "minecraft_version" to "minecraft_version"(), + "create_version" to "create_fabric_version"(), // on fabric, use the entire version, unlike forge + "voicechat_api_version" to "voicechat_api_version"() + ) + + properties.forEach { (k, v) -> inputs.property(k, v) } + + filesMatching("fabric.mod.json") { + expand(properties) + } +} + +val getGitHash = { -> + val stdout = ByteArrayOutputStream() + exec { + commandLine("git", "rev-parse", "HEAD") + standardOutput = stdout + } + stdout.toString().trim() +} + +val hasUnstaged = { -> + val stdout = ByteArrayOutputStream() + exec { + commandLine("git", "status", "--porcelain") + standardOutput = stdout + } + val result = stdout.toString().replace("M gradlew", "").trim() + if (result.isNotEmpty()) + println("Found stageable results:\n${result}\n") + result.isNotEmpty() +} + +tasks.shadowJar { + exclude("architectury.common.json") + configurations = listOf(shadowCommon) + archiveClassifier = "dev-shadow" +} + +tasks.remapJar { + injectAccessWidener = true + inputFile.set(tasks.shadowJar.get().archiveFile) + dependsOn(tasks.shadowJar) + archiveClassifier = null +} + +tasks.jar { + archiveClassifier = "dev" + + val gitHash = "\"${getGitHash()}" + (if (hasUnstaged()) "-modified" else "") + "\"" + + manifest { + attributes(mapOf("Git-Hash" to gitHash)) + } +} + +tasks.sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar") + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) + + val gitHash = "\"${getGitHash()}" + (if (hasUnstaged()) "-modified" else "") + "\"" + + manifest { + attributes(mapOf("Git-Hash" to gitHash)) + } +} + +components.getByName("java") { + this as AdhocComponentWithVariants + this.withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) { + skip() + } +} + +publishMods { + file(tasks.remapJar.get().archiveFile) + version.set(project.version.toString()) + changelog = dev.ithundxr.silk.ChangelogText.getChangelogText(rootProject).toString() + type = STABLE + displayName = "Steam 'n' Rails ${"mod_version"()} Fabric ${"minecraft_version"()}" + modLoaders.add("fabric") + modLoaders.add("quilt") + + curseforge { + projectId = "curseforge_id"() + accessToken = System.getenv("CURSEFORGE_TOKEN") + minecraftVersions.add("minecraft_version"()) + + requires { + slug = "create-fabric" + } + } + + modrinth { + projectId = "modrinth_id"() + accessToken = System.getenv("MODRINTH_TOKEN") + minecraftVersions.add("minecraft_version"()) + + requires { + slug = "create-fabric" + } + } +} + +publishing { + publications { + create("mavenFabric") { + artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + from(components["java"]) + } + } + + repositories { + if (System.getenv("MAVEN_TOKEN") != null) { + if (System.getenv("RELEASE_BUILD")?.toBoolean() == true) { + maven { + url = uri("https://maven.ithundxr.dev/releases") + credentials { + username = "railways-github" + password = System.getenv("MAVEN_TOKEN") + } + } + } else { + maven { + url = uri("https://maven.ithundxr.dev/snapshots") + credentials { + username = "railways-github" + password = System.getenv("MAVEN_TOKEN") + } + } + } + } + } +} + +operator fun String.invoke(): String { + return rootProject.ext[this] as? String + ?: throw IllegalStateException("Property $this is not defined") +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle.kts similarity index 77% rename from forge/build.gradle rename to forge/build.gradle.kts index 8b81750a2..600846e83 100644 --- a/forge/build.gradle +++ b/forge/build.gradle.kts @@ -1,17 +1,18 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" - id "me.modmuss50.mod-publish-plugin" + id("com.github.johnrengelman.shadow") version "7.1.2" + id("me.modmuss50.mod-publish-plugin") } loom { - accessWidenerPath = project(":common").loom.accessWidenerPath + val common = project(":common") + accessWidenerPath = common.loom.accessWidenerPath forge { mixinConfig("railways-common.mixins.json") mixinConfig("railways.mixins.json") convertAccessWideners = true - extraAccessWideners.add loom.accessWidenerPath.get().asFile.name + extraAccessWideners.add = loom.accessWidenerPath.get().asFile.name } } @@ -20,69 +21,70 @@ architectury { forge() } +val common: Configuration by configurations.creating +val shadowCommon: Configuration by configurations.creating +val developmentForge: Configuration by configurations.getting + configurations { - 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 - developmentForge.extendsFrom common + compileOnly.configure { extendsFrom(common) } + runtimeOnly.configure { extendsFrom(common) } + developmentForge.extendsFrom(common) } - repositories { // mavens for Forge-exclusives - maven { url = "https://maven.theillusivec4.top/" } // Curios + maven { url = uri("https://maven.theillusivec4.top/") } // Curios maven { // Create Forge and Registrate Forge - url = "https://maven.tterrag.com/" + url = uri("https://maven.tterrag.com/") content { includeGroup("com.tterrag.registrate") includeGroup("com.simibubi.create") } } maven { - url = "https://maven.blamejared.com/" + url = uri("https://maven.blamejared.com/") content { includeGroup("at.petra-k") includeGroup("vazkii.patchouli") } } // JEI, Hex Casting maven { - name = 'Ladysnake Mods' - url = 'https://maven.ladysnake.org/releases' + name = "Ladysnake Mods" + url = uri("https://maven.ladysnake.org/releases") content { includeGroup("dev.onyxstudios.cardinal-components-api") } } // Cardinal Components (Hex Casting dependency) maven { - url = "https://jitpack.io" + url = uri("https://jitpack.io") content { includeGroupByRegex("com.github.*") } } // Pehkui (Hex Casting dependency) - maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes (Hex Casting dependency) + maven { url = uri("https://maven.jamieswhiteshirt.com/libs-release") } // Reach Entity Attributes (Hex Casting dependency) // Add KFF Maven repository (Hex Casting dependency) maven { - name = 'Kotlin for Forge' - url = 'https://thedarkcolour.github.io/KotlinForForge/' + name = "Kotlin for Forge" + url = uri("https://thedarkcolour.github.io/KotlinForForge/") content { includeGroup("thedarkcolour") } } maven { - url "https://cursemaven.com" + url = uri("https://cursemaven.com") content { - includeGroup "curse.maven" + includeGroup = "curse.maven" } } // Biomes O' Plenty } dependencies { - forge("net.minecraftforge:forge:${minecraft_version}-${forge_version}") - common(project(path: ":common", configuration: "namedElements")) { transitive = false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } + forge("net.minecraftforge:forge:${"minecraft_version"()}-${"forge_version"()}") + common(project(":common", "namedElements")) { isTransitive = false } + shadowCommon(project(":common", "transformProductionForge")) { isTransitive = false } // Create and its dependencies - modImplementation("com.simibubi.create:create-${minecraft_version}:${create_forge_version}:slim") { transitive = false } + modImplementation("com.simibubi.create:create-${minecraft_version}:${create_forge_version}:slim") { isTransitive = false } modImplementation("com.tterrag.registrate:Registrate:${registrate_forge_version}") modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_forge_version}") @@ -96,10 +98,10 @@ dependencies { modLocalRuntime("maven.modrinth:journeymap:${journeymap_version}-forge") modCompileOnly("info.journeymap:journeymap-api:${journeymap_api_version}-SNAPSHOT") // for some reason this is needed explicitly - modCompileOnly "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}" + modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}") if (enable_simple_voice_chat.toBoolean()) { - modLocalRuntime "maven.modrinth:simple-voice-chat:forge-${voicechat_version}" + modLocalRuntime("maven.modrinth:simple-voice-chat:forge-${voicechat_version}") } // mod compat for tracks @@ -173,7 +175,7 @@ processResources { def getGitHash = { -> def stdout = new ByteArrayOutputStream() exec { - commandLine 'git', 'rev-parse', 'HEAD' + commandLine "git", "rev-parse", "HEAD" standardOutput = stdout } return stdout.toString().trim() @@ -182,7 +184,7 @@ def getGitHash = { -> def hasUnstaged = { -> def stdout = new ByteArrayOutputStream() exec { - commandLine 'git', 'status', '--porcelain' + commandLine "git", "status", "--porcelain" standardOutput = stdout } def result = stdout.toString().replaceAll("M gradlew", "").trim() @@ -276,10 +278,10 @@ publishing { } repositories { - if (System.getenv("MAVEN_TOKEN")) { - if (System.getenv("RELEASE_BUILD")) { + if (System.getenv("MAVEN_TOKEN") != null) { + if (System.getenv("RELEASE_BUILD")?.toBoolean() == true) { maven { - url "https://maven.ithundxr.dev/releases" + url = uri("https://maven.ithundxr.dev/releases") credentials { username = "railways-github" password = System.getenv("MAVEN_TOKEN") @@ -287,7 +289,7 @@ publishing { } } else { maven { - url "https://maven.ithundxr.dev/snapshots" + url = uri("https://maven.ithundxr.dev/snapshots") credentials { username = "railways-github" password = System.getenv("MAVEN_TOKEN") @@ -297,3 +299,8 @@ publishing { } } } + +operator fun String.invoke(): String { + return rootProject.ext[this] as? String + ?: throw IllegalStateException("Property $this is not defined") +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 0acc95929..000000000 --- a/settings.gradle +++ /dev/null @@ -1,15 +0,0 @@ -pluginManagement { - repositories { - maven { url = "https://maven.fabricmc.net/" } - maven { url = "https://maven.architectury.dev/" } - maven { url = "https://maven.minecraftforge.net/" } - maven { url = "https://maven.quiltmc.org/repository/release" } - gradlePluginPortal() - } -} - -include("common") -include("fabric") -include("forge") - -rootProject.name = "Railway" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..e5a9fd424 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + maven { url = uri("https://maven.fabricmc.net/") } + maven { url = uri("https://maven.architectury.dev/") } + maven { url = uri("https://maven.minecraftforge.net/") } + maven { url = uri("https://maven.quiltmc.org/repository/release") } + gradlePluginPortal() + } +} + +include("common") +include("fabric") +include("forge") + +rootProject.name = "Railway" From 31f02729a5a1919835d60f123493295e04304537 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 29 Jan 2024 16:25:11 -0500 Subject: [PATCH 2/8] kotlin transformation is complete >:3 --- forge/build.gradle.kts | 185 +++++++++++++++++++++-------------------- 1 file changed, 94 insertions(+), 91 deletions(-) diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 600846e83..081102366 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,3 +1,5 @@ +import java.io.ByteArrayOutputStream + plugins { id("com.github.johnrengelman.shadow") version "7.1.2" id("me.modmuss50.mod-publish-plugin") @@ -12,7 +14,7 @@ loom { mixinConfig("railways.mixins.json") convertAccessWideners = true - extraAccessWideners.add = loom.accessWidenerPath.get().asFile.name + extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name) } } @@ -73,7 +75,7 @@ repositories { maven { url = uri("https://cursemaven.com") content { - includeGroup = "curse.maven" + includeGroup("curse.maven") } } // Biomes O' Plenty } @@ -84,9 +86,9 @@ dependencies { shadowCommon(project(":common", "transformProductionForge")) { isTransitive = false } // Create and its dependencies - modImplementation("com.simibubi.create:create-${minecraft_version}:${create_forge_version}:slim") { isTransitive = false } - modImplementation("com.tterrag.registrate:Registrate:${registrate_forge_version}") - modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_forge_version}") + modImplementation("com.simibubi.create:create-${"minecraft_version"()}:${"create_forge_version"()}:slim") { isTransitive = false } + modImplementation("com.tterrag.registrate:Registrate:${"registrate_forge_version"()}") + modImplementation("com.jozufozu.flywheel:flywheel-forge-${"minecraft_version"()}:${"flywheel_forge_version"()}") // Development QOL // modLocalRuntime("mezz.jei:jei-${minecraft_version}-forge:${jei_forge_version}") @@ -95,163 +97,164 @@ dependencies { // modCompileOnly("mezz.jei:jei-${minecraft_version}:${jei_forge_version}:api") // Test with JourneyMap in dev - modLocalRuntime("maven.modrinth:journeymap:${journeymap_version}-forge") - modCompileOnly("info.journeymap:journeymap-api:${journeymap_api_version}-SNAPSHOT") // for some reason this is needed explicitly + modLocalRuntime("maven.modrinth:journeymap:${"journeymap_version"()}-forge") + modCompileOnly("info.journeymap:journeymap-api:${"journeymap_api_version"()}-SNAPSHOT") // for some reason this is needed explicitly - modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}") + modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${"voicechat_api_version"()}") - if (enable_simple_voice_chat.toBoolean()) { - modLocalRuntime("maven.modrinth:simple-voice-chat:forge-${voicechat_version}") + if ("enable_simple_voice_chat"().toBoolean()) { + modLocalRuntime("maven.modrinth:simple-voice-chat:forge-${"voicechat_version"()}") } // mod compat for tracks - if (enable_hexcasting.toBoolean()) { - modLocalRuntime("at.petra-k.paucal:paucal-forge-${minecraft_version}:${paucal_version}") - modLocalRuntime("at.petra-k.hexcasting:hexcasting-forge-${minecraft_version}:${hexcasting_version}") { - exclude group: "com.github.Virtuoel", module: "Pehkui" - exclude group: "net.minecraftforge", module: "forge" - exclude group: "top.theillusivec4.curios", module: "curios-forge" - exclude group: "mezz.jei", module: "jei-1.19.2-forge" + if ("enable_hexcasting"().toBoolean()) { + modLocalRuntime("at.petra-k.paucal:paucal-forge-${"minecraft_version"()}:${"paucal_version"()}") + modLocalRuntime("at.petra-k.hexcasting:hexcasting-forge-${"minecraft_version"()}:${"hexcasting_version"()}") { + exclude(group = "com.github.Virtuoel", module = "Pehkui") + exclude(group = "net.minecraftforge", module = "forge") + exclude(group = "top.theillusivec4.curios", module = "curios-forge") + exclude(group = "mezz.jei", module = "jei-1.19.2-forge") } //modApi("com.github.Virtuoel:Pehkui:${pehkui_version}-${minecraft_version}-forge") // probably not needed - modLocalRuntime("vazkii.patchouli:Patchouli:${minecraft_version}-${patchouli_version}") - modLocalRuntime("thedarkcolour:kotlinforforge:${kotlin_for_forge_version}") + modLocalRuntime("vazkii.patchouli:Patchouli:${"minecraft_version"()}-${"patchouli_version"()}") + modLocalRuntime("thedarkcolour:kotlinforforge:${"kotlin_for_forge_version"()}") } - if (enable_byg.toBoolean()) { - modLocalRuntime("maven.modrinth:biomesyougo:${byg_version}-forge") + if ("enable_byg"().toBoolean()) { + modLocalRuntime("maven.modrinth:biomesyougo:${"byg_version"()}-forge") } - if (enable_byg.toBoolean() || enable_bop.toBoolean()) { - modLocalRuntime("maven.modrinth:terrablender:${terrablender_version_forge}") + if ("enable_byg"().toBoolean() || "enable_bop"().toBoolean()) { + modLocalRuntime("maven.modrinth:terrablender:${"terrablender_version_forge"()}") } - if (enable_bop.toBoolean()) { - modLocalRuntime("curse.maven:biomesoplenty-220318:${bop_version}") + if ("enable_bop"().toBoolean()) { + modLocalRuntime("curse.maven:biomesoplenty-220318:${"bop_version"()}") } - if (enable_dnd.toBoolean()) { - modLocalRuntime("maven.modrinth:create-dreams-and-desires:${dnd_version}") + if ("enable_dnd"().toBoolean()) { + modLocalRuntime("maven.modrinth:create-dreams-and-desires:${"dnd_version"()}") } - if (enable_quark.toBoolean()) { - modLocalRuntime("maven.modrinth:quark:${minecraft_version}-${quark_version}") - modLocalRuntime("vazkii.autoreglib:AutoRegLib:${arl_version}") + if ("enable_quark"().toBoolean()) { + modLocalRuntime("maven.modrinth:quark:${"minecraft_version"()}-${"quark_version"()}") + modLocalRuntime("vazkii.autoreglib:AutoRegLib:${"arl_version"()}") } - if (enable_sodium_rubidium.toBoolean()) { - modLocalRuntime("maven.modrinth:rubidium:${rubidium_version}") + if ("enable_sodium_rubidium"().toBoolean()) { + modLocalRuntime("maven.modrinth:rubidium:${"rubidium_version"()}") } - if (enable_eb.toBoolean()) { - modImplementation("com.rabbitminers:extendedbogeys-forge:${EB_verison}+forge-patch-") + if ("enable_eb"().toBoolean()) { + modImplementation("com.rabbitminers:extendedbogeys-forge:${"EB_verison"()}+forge-patch-") } - if (enable_sc.toBoolean()) { - modLocalRuntime("curse.maven:securitycraft-64760:${sc_version}") + if ("enable_sc"().toBoolean()) { + modLocalRuntime("curse.maven:securitycraft-64760:${"sc_version"()}") } - compileOnly("io.github.llamalad7:mixinextras-common:${mixin_extras_version}") - include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-forge:${mixin_extras_version}"))) + val mixinExtras = "io.github.llamalad7:mixinextras-forge:${"mixin_extras_version"()}" + + compileOnly("io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}") + annotationProcessor(mixinExtras) + implementation(mixinExtras) + include(mixinExtras) } -processResources { +tasks.processResources { // include packs from(rootProject.file("common/src/main/resources")) { include("resourcepacks/") } // set up properties for filling into metadata - Map properties = Map.of( - "version", version as String, - "forge_version", forge_version.split("\\.")[0], // only specify major version of forge - "minecraft_version", minecraft_version, - "create_version", create_forge_version.split("-")[0], // cut off build number - "voicechat_api_version", voicechat_api_version + val properties = mapOf( + "version" to version as String, + "forge_version" to "forge_version"().split("\\.")[0], // only specify major version of forge + "minecraft_version" to "minecraft_version"(), + "create_version" to "create_forge_version"().split("-")[0], // cut off build number + "voicechat_api_version" to "voicechat_api_version"() ) - properties.forEach((k, v) -> inputs.property(k, v)) + + properties.forEach { (k, v) -> inputs.property(k, v) } filesMatching("META-INF/mods.toml") { - expand properties + expand(properties) } } -def getGitHash = { -> - def stdout = new ByteArrayOutputStream() +val getGitHash = { -> + val stdout = ByteArrayOutputStream() exec { - commandLine "git", "rev-parse", "HEAD" + commandLine("git", "rev-parse", "HEAD") standardOutput = stdout } - return stdout.toString().trim() + stdout.toString().trim() } -def hasUnstaged = { -> - def stdout = new ByteArrayOutputStream() +val hasUnstaged = { -> + val stdout = ByteArrayOutputStream() exec { - commandLine "git", "status", "--porcelain" + commandLine("git", "status", "--porcelain") standardOutput = stdout } - def result = stdout.toString().replaceAll("M gradlew", "").trim() - if (!result.isEmpty()) + val result = stdout.toString().replace("M gradlew", "").trim() + if (result.isNotEmpty()) println("Found stageable results:\n${result}\n") - return !result.isEmpty() + result.isNotEmpty() } -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] +tasks.shadowJar { + exclude("fabric.mod.json") + exclude("architectury.common.json") + configurations = listOf(shadowCommon) archiveClassifier = "dev-shadow" } -remapJar { - inputFile.set shadowJar.archiveFile - dependsOn shadowJar +tasks.remapJar { + inputFile.set(tasks.shadowJar.get().archiveFile) + dependsOn(tasks.shadowJar) archiveClassifier = null } -jar { +tasks.jar { archiveClassifier = "dev" - String gitHash = "\"${getGitHash()}" + (hasUnstaged() ? "-modified" : "") + "\"" + val gitHash = "\"${getGitHash()}" + (if (hasUnstaged()) "-modified" else "") + "\"" manifest { - attributes([ - "Git-Hash": gitHash - ]) + attributes(mapOf("Git-Hash" to gitHash)) } } -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } +tasks.sourcesJar { + val commonSources = project(":common").tasks.getByName("sourcesJar") + dependsOn(commonSources) + from(commonSources.archiveFile.map { zipTree(it) }) - String gitHash = "\"${getGitHash()}" + (hasUnstaged() ? "-modified" : "") + "\"" + val gitHash = "\"${getGitHash()}" + (if (hasUnstaged()) "-modified" else "") + "\"" manifest { - attributes([ - "Git-Hash": gitHash - ]) + attributes(mapOf("Git-Hash" to gitHash)) } } -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { +components.getByName("java") { + this as AdhocComponentWithVariants + this.withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) { skip() } } publishMods { - file = remapJar.archiveFile - version = project.version - changelog = getChangelogText() + file(tasks.remapJar.get().archiveFile) + version.set(project.version.toString()) + changelog = dev.ithundxr.silk.ChangelogText.getChangelogText(rootProject).toString() type = STABLE - displayName = "Steam 'n' Rails $mod_version Forge $minecraft_version" + displayName = "Steam 'n' Rails ${"mod_version"()} Forge ${"minecraft_version"()}" modLoaders.add("forge") modLoaders.add("neoforge") curseforge { - projectId = curseforge_id + projectId = "curseforge_id"() accessToken = System.getenv("CURSEFORGE_TOKEN") - minecraftVersions.add(minecraft_version) + minecraftVersions.add("minecraft_version"()) requires { slug = "create" @@ -259,9 +262,9 @@ publishMods { } modrinth { - projectId = modrinth_id + projectId = "modrinth_id"() accessToken = System.getenv("MODRINTH_TOKEN") - minecraftVersions.add(minecraft_version) + minecraftVersions.add("minecraft_version"()) requires { slug = "create" @@ -271,9 +274,9 @@ publishMods { publishing { publications { - mavenCommon(MavenPublication) { - artifactId = "${archives_base_name}-${project.name}-${minecraft_version}" - from components.java + create("mavenFabric") { + artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + from(components["java"]) } } From 0913ed73190b683136376d8584cffbf47edbe801 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 29 Jan 2024 16:37:13 -0500 Subject: [PATCH 3/8] kotlinification has been completed. --- build.gradle.kts | 13 +------------ common/build.gradle.kts | 17 +++++++++++------ fabric/build.gradle.kts | 37 +++++++++++++++++++++++-------------- forge/build.gradle.kts | 7 +++++++ 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a6f0f3e50..54e31b245 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,21 +46,10 @@ subprojects { maven { url = uri("https://maven.maxhenkel.de/repository/public") } // Simple Voice Chat } - val loom = project.extensions.getByName("loom") - -// loom { -// silentMojangMappingsLicense() -// runs.configureEach { -// vmArg("-Dmixin.debug.export=true") -// vmArg("-Dmixin.env.remapRefMap=true") -// vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg") -// } -// } - dependencies { "minecraft"("com.mojang:minecraft:${"minecraft_version"()}") // layered mappings - Mojmap names, parchment and QM docs and parameters - "mappings"(loom.layered { + "mappings"(project.extensions.getByName("loom").layered { mappings("org.quiltmc:quilt-mappings:${"minecraft_version"()}+build.${"qm_version"()}:intermediary-v2") parchment("org.parchmentmc.data:parchment-${"minecraft_version"()}:${"parchment_version"()}@zip") officialMojangMappings { nameSyntheticMembers = false } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 3564dab79..11468cd17 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -65,12 +65,17 @@ tasks.processResources { exclude("**/*.bbmodel", "**/*.lnk", "**/*.xcf", "**/*.md", "**/*.txt", "**/*.blend", "**/*.blend1", "**/PlatformMethods.class") // Minify all .json files in built jars - //fixme -// doLast { -// fileTree(dir = outputs.files.asPath, include = "**/*.json").forEach { file -> -// file.writeText(JsonOutput.toJson(JsonSlurper().parseText(file.readText()))) -// } -// } + doLast { + val outputDir = File(outputs.files.asPath) + outputDir.walkTopDown() + .filter { it.isFile && it.extension == "json" } + .forEach { file -> + val jsonContent = file.readText() + val parsedJson = JsonSlurper().parseText(jsonContent) + val updatedJson = JsonOutput.toJson(parsedJson) + file.writeText(updatedJson) + } + } } sourceSets.main { diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 9ab81839b..b5bca0079 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,3 +1,5 @@ +import net.fabricmc.loom.api.LoomGradleExtensionAPI +import net.fabricmc.loom.configuration.FabricApiExtension.DataGenerationSettings import java.io.ByteArrayOutputStream plugins { @@ -14,20 +16,27 @@ loom { val common = project(":common") accessWidenerPath = common.loom.accessWidenerPath - //fixme -// runs { -// datagen { -// client() -// -// name = "Minecraft Data" -// vmArg = "-Dfabric-api.datagen" -// vmArg = "-Dfabric-api.datagen.output-dir=${common.file("src/generated/resources")}" -// vmArg = "-Dfabric-api.datagen.modid=railways" -// vmArg = "-Dporting_lib.datagen.existing_resources=${common.file("src/main/resources")}" -// -// environmentVariable("DATAGEN", "TRUE") -// } -// } + silentMojangMappingsLicense() + runs.configureEach { + vmArg("-Dmixin.debug.export=true") + vmArg("-Dmixin.env.remapRefMap=true") + vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg") + } + + + runs { + create("datagen") { + client() + + name = "Minecraft Data" + vmArg("-Dfabric-api.datagen") + vmArg("-Dfabric-api.datagen.output-dir=${common.file("src/generated/resources")}") + vmArg("-Dfabric-api.datagen.modid=railways") + vmArg("-Dporting_lib.datagen.existing_resources=${common.file("src/main/resources")}") + + environmentVariable("DATAGEN", "TRUE") + } + } } val common: Configuration by configurations.creating diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 081102366..082382b33 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -9,6 +9,13 @@ loom { val common = project(":common") accessWidenerPath = common.loom.accessWidenerPath + silentMojangMappingsLicense() + runs.configureEach { + vmArg("-Dmixin.debug.export=true") + vmArg("-Dmixin.env.remapRefMap=true") + vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg") + } + forge { mixinConfig("railways-common.mixins.json") mixinConfig("railways.mixins.json") From f59261f9297d47b7bc3d3cfc88a6b900ec97fcb3 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 29 Jan 2024 16:47:35 -0500 Subject: [PATCH 4/8] fixy fixy --- common/build.gradle.kts | 2 +- fabric/build.gradle.kts | 2 +- forge/build.gradle.kts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 11468cd17..6de5c35bf 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -89,7 +89,7 @@ sourceSets.main { publishing { publications { create("mavenCommon") { - artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + artifactId = "${"archives_base_name"()}-${project.name}-${"minecraft_version"()}" from(components["java"]) } } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index b5bca0079..e1ae79d3b 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -273,7 +273,7 @@ publishMods { publishing { publications { create("mavenFabric") { - artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + artifactId = "${"archives_base_name"()}-${project.name}-${"minecraft_version"()}" from(components["java"]) } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 082382b33..46e93dad6 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -281,8 +281,8 @@ publishMods { publishing { publications { - create("mavenFabric") { - artifactId = "${base.archivesName}-${project.name}-${"minecraft_version"()}" + create("mavenForge") { + artifactId = "${"archives_base_name"()}-${project.name}-${"minecraft_version"()}" from(components["java"]) } } From 42df5520a47fa29f2424f1abe31e5bd97a9e8bcb Mon Sep 17 00:00:00 2001 From: IThundxr Date: Mon, 29 Jan 2024 16:53:06 -0500 Subject: [PATCH 5/8] fixy fixy x2 --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 54e31b245..f6d1c1fc0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import net.fabricmc.loom.api.LoomGradleExtensionAPI +import net.fabricmc.loom.task.RemapJarTask plugins { java @@ -58,7 +59,7 @@ subprojects { tasks.register("moveBuiltJars") { if (project.path != ":common") { - val remapJar by project.tasks.named("remapJar") + val remapJar by project.tasks.named("remapJar") dependsOn(remapJar) from(remapJar) } From 620516bcedf0edf3542f75dbc36b046c3f3d1f4e Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 31 Jan 2024 20:58:28 -0500 Subject: [PATCH 6/8] update update update --- build.gradle.kts | 6 ++++++ common/build.gradle.kts | 18 +----------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f6d1c1fc0..cd5f0aeea 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,6 +47,12 @@ subprojects { maven { url = uri("https://maven.maxhenkel.de/repository/public") } // Simple Voice Chat } + configurations.configureEach { + resolutionStrategy { + force("net.fabricmc:fabric-loader:${"fabric_loader_version"()}") + } + } + dependencies { "minecraft"("com.mojang:minecraft:${"minecraft_version"()}") // layered mappings - Mojmap names, parchment and QM docs and parameters diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 6de5c35bf..bce111ff4 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,6 +1,3 @@ -import groovy.json.JsonOutput -import groovy.json.JsonSlurper - loom { accessWidenerPath = file("src/main/resources/railways.accesswidener") } @@ -61,21 +58,8 @@ tasks.processResources { // must be part of primary mod to be findable exclude("resourcepacks/") - // dont add development or to-do files into built jar + // don't add development or to-do files into built jar exclude("**/*.bbmodel", "**/*.lnk", "**/*.xcf", "**/*.md", "**/*.txt", "**/*.blend", "**/*.blend1", "**/PlatformMethods.class") - - // Minify all .json files in built jars - doLast { - val outputDir = File(outputs.files.asPath) - outputDir.walkTopDown() - .filter { it.isFile && it.extension == "json" } - .forEach { file -> - val jsonContent = file.readText() - val parsedJson = JsonSlurper().parseText(jsonContent) - val updatedJson = JsonOutput.toJson(parsedJson) - file.writeText(updatedJson) - } - } } sourceSets.main { From ac3d93c404c8caaa81d182b48af73bb2b966f661 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 31 Jan 2024 21:29:06 -0500 Subject: [PATCH 7/8] last bits --- changelog.md | 3 ++- .../src/main/java/com/railwayteam/railways/config/CClient.java | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 4f173efc6..66ceba6a4 100644 --- a/changelog.md +++ b/changelog.md @@ -29,7 +29,6 @@ Changes - Remote Conductor-controlled trains adjust speed based on signal strength - Smoke rework 2.0: more minecraft-style smoke, with config for old smoke - Train status messages now include coordinates -- Make optifine warning screen easier to skip - Soul fire smoke in smoke stacks, clicking a smokestack with soul soil or soul sand will make it output soul fire themed smoke - Smokestacks can be dyed via being clicked with dye - Smokestacks show their dye color/style when wearing goggles @@ -37,6 +36,7 @@ Changes - Radiator fans can now be placed in any direction - Creeper explosions and Ghast Fireballs no longer break tracks - Remastered Monobogeys, Single Axle, Double Axle and Triple Axle Bogies +- Removed optifine warning screen Fixes - Mixin conflict with VS2 @@ -48,6 +48,7 @@ Fixes - Change conductor cap offset on players to fix clipping with some skins - Rework a conductor spy mixin for Tweakeroo freecam compat - Offset train assembly overlay on encased tracks +- Made the mod work with optifine again ------------------------------------------------------ Version 1.5.1 ------------------------------------------------------ diff --git a/common/src/main/java/com/railwayteam/railways/config/CClient.java b/common/src/main/java/com/railwayteam/railways/config/CClient.java index e1ab63bf0..cddfa5774 100644 --- a/common/src/main/java/com/railwayteam/railways/config/CClient.java +++ b/common/src/main/java/com/railwayteam/railways/config/CClient.java @@ -11,7 +11,6 @@ public class CClient extends ConfigBase { // no group - public final ConfigBool disableOptifineWarning = b(false, "disableOptifineWarning", Comments.disableOptifineWarning); public final ConfigBool showExtendedCouplerDebug = b(false, "showExtendedCouplerDebug", Comments.showExtendedCouplerDebug); public final ConfigBool skipClientDerailing = b(false, "skipClientDerailing", Comments.skipClientDerailing); public final ConfigBool useConductorSpyShader = b(true, "useConductorSpyShader", Comments.useConductorSpyShader); @@ -50,7 +49,6 @@ private static class Comments { static String client = "Client-only settings - If you're looking for general settings, look inside your worlds serverconfig folder!"; - static String disableOptifineWarning = "Disable the optifine warning screen [DANGER]: Using optifine With Steam 'n' Rails may cause issues and you will not get any support for optifine related issues."; static String showExtendedCouplerDebug = "Show extended debug info in coupler goggle overlay"; static String skipClientDerailing = "Skip clientside train derailing. This prevents stuttering when a train places tracks, but trains will not appear derailed when they crash"; static String useConductorSpyShader = "Use a scanline shader when spying through a conductor"; From 5a134ee50897f2bb88852f6442bf1552227fdbaf Mon Sep 17 00:00:00 2001 From: IThundxr Date: Wed, 7 Feb 2024 16:21:29 -0500 Subject: [PATCH 8/8] kotlin fun kotlin fun kotlin fun kotlin fun kotlin fun kotlin fun kotlin fun kotlin fun --- fabric/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index e1ae79d3b..0280b2b80 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -166,7 +166,7 @@ tasks.processResources { "fabric_loader_version" to "fabric_loader_version"(), "fabric_api_version" to "fabric_api_version"(), "minecraft_version" to "minecraft_version"(), - "create_version" to "create_fabric_version"(), // on fabric, use the entire version, unlike forge + "create_version" to "create_fabric_version"().split("\\+")[0], // Trim +mcX.XX.X from version string "voicechat_api_version" to "voicechat_api_version"() )