|
1 | | -@file:Suppress("UnstableApiUsage", "PropertyName") |
2 | | - |
3 | | -import dev.deftu.gradle.utils.GameSide |
4 | | -import dev.deftu.gradle.utils.includeOrShade |
| 1 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 2 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
5 | 3 |
|
6 | 4 | plugins { |
7 | | - java |
8 | | - kotlin("jvm") |
9 | | - id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders. |
10 | | - id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc. |
11 | | - id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources. |
12 | | - id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files. |
13 | | - id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those! |
14 | | - id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you. |
15 | | - id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth. |
| 5 | + id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT" |
| 6 | + id("org.jetbrains.kotlin.jvm") version "2.3.0" |
| 7 | + id("dev.deftu.gradle.bloom") version "0.2.0" |
16 | 8 | } |
17 | 9 |
|
18 | | -toolkitMultiversion { |
19 | | - moveBuildsToRootProject = true |
| 10 | +val modid = property("mod.id") |
| 11 | +val modname = property("mod.name") |
| 12 | +val modversion = property("mod.version") |
| 13 | +val mcversion = property("minecraft_version") |
| 14 | + |
| 15 | +base { |
| 16 | + archivesName.set(property("mod.id") as String) |
20 | 17 | } |
21 | 18 |
|
22 | | -toolkitLoomHelper { |
23 | | - useOneConfig { |
24 | | - version = "1.0.0-alpha.153" |
25 | | - loaderVersion = "1.1.0-alpha.49" |
| 19 | +repositories { |
| 20 | + maven("https://maven.parchmentmc.org") |
| 21 | + maven("https://repo.polyfrost.org/releases") |
| 22 | + maven("https://repo.polyfrost.org/snapshots") |
| 23 | + maven("https://maven.gegy.dev/releases") |
| 24 | +} |
26 | 25 |
|
27 | | - usePolyMixin = true |
28 | | - polyMixinVersion = "0.8.4+build.2" |
| 26 | +loom { |
| 27 | + runConfigs.all { |
| 28 | + ideConfigGenerated(stonecutter.current.isActive) |
| 29 | + runDir = "../../run" // This sets the run folder for all mc versions to the same folder. Remove this line if you want individual run folders. |
| 30 | + } |
29 | 31 |
|
30 | | - applyLoaderTweaker = true |
| 32 | + runConfigs.remove(runConfigs["server"]) // Removes server run configs |
| 33 | +} |
31 | 34 |
|
32 | | - for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) { |
33 | | - +module |
| 35 | +dependencies { |
| 36 | + minecraft("com.mojang:minecraft:${property("minecraft_version")}") |
| 37 | + @Suppress("UnstableApiUsage") |
| 38 | + mappings(loom.layered { |
| 39 | + officialMojangMappings() |
| 40 | + optionalProp("${property("parchment_version")}") { |
| 41 | + parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:$it@zip") |
34 | 42 | } |
35 | | - } |
36 | | - useDevAuth("1.2.1") |
37 | | - useMixinExtras("0.4.1") |
| 43 | + optionalProp("${property("yalmm_version")}") { |
| 44 | + mappings("dev.lambdaurora:yalmm-mojbackward:${property("minecraft_version")}+build.$it") |
| 45 | + } |
| 46 | + }) |
| 47 | + modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}") |
| 48 | + modImplementation("org.polyfrost.oneconfig:${property("minecraft_version")}-fabric:1.0.0-alpha.181") |
| 49 | + modImplementation("org.polyfrost.oneconfig:commands:1.0.0-alpha.181") |
| 50 | + modImplementation("org.polyfrost.oneconfig:config:1.0.0-alpha.181") |
| 51 | + modImplementation("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.181") |
| 52 | + modImplementation("org.polyfrost.oneconfig:events:1.0.0-alpha.181") |
| 53 | + modImplementation("org.polyfrost.oneconfig:internal:1.0.0-alpha.181") |
| 54 | + modImplementation("org.polyfrost.oneconfig:ui:1.0.0-alpha.181") |
| 55 | + modImplementation("org.polyfrost.oneconfig:utils:1.0.0-alpha.181") |
| 56 | + modImplementation("org.polyfrost.oneconfig:hud:1.0.0-alpha.181") |
| 57 | + |
| 58 | + implementation("dev.deftu:commons-suncalc:0.1.0")!! |
| 59 | +} |
38 | 60 |
|
39 | | - // Turns off the server-side run configs, as we're building a client-sided mod. |
40 | | - disableRunConfigs(GameSide.SERVER) |
| 61 | +bloom { |
| 62 | + replacement("@MOD_ID@", modid!!) |
| 63 | + replacement("@MOD_NAME@", modname!!) |
| 64 | + replacement("@MOD_VERSION@", modversion!!) |
| 65 | +} |
41 | 66 |
|
42 | | - // Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes. |
43 | | - if (!mcData.isNeoForge) { |
44 | | - useMixinRefMap(modData.id) |
45 | | - } |
| 67 | +tasks.processResources { |
| 68 | + val props = mapOf( |
| 69 | + "mod_id" to modid, |
| 70 | + "mod_name" to modname, |
| 71 | + "mod_version" to modversion, |
| 72 | + "mc_version" to mcversion, |
| 73 | + "loader_version" to providers.gradleProperty("loader_version").get() |
| 74 | + ) |
46 | 75 |
|
47 | | - if (mcData.isForge) { |
48 | | - // Configures the Mixin tweaker if we are building for Forge. |
49 | | - useForgeMixin(modData.id) |
| 76 | + inputs.properties(props) |
| 77 | + |
| 78 | + filesMatching("fabric.mod.json") { |
| 79 | + expand(props) |
50 | 80 | } |
51 | 81 | } |
52 | 82 |
|
53 | | -dependencies { |
54 | | - implementation(includeOrShade("dev.deftu:commons-suncalc:0.1.0")!!) |
55 | | - |
56 | | - // Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful). |
57 | | - if (mcData.isFabric) { |
58 | | - if (mcData.isLegacyFabric) { |
59 | | - // 1.8.9 - 1.13 |
60 | | - modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}") |
61 | | - } else { |
62 | | - // 1.16.5+ |
63 | | - modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}") |
64 | | - } |
| 83 | +tasks.withType<JavaCompile>().configureEach { |
| 84 | + options.release.set(21) |
| 85 | +} |
| 86 | + |
| 87 | +tasks.withType<KotlinCompile>().configureEach { |
| 88 | + compilerOptions.jvmTarget.set(JvmTarget.JVM_21) |
| 89 | +} |
| 90 | + |
| 91 | +java { |
| 92 | + withSourcesJar() |
| 93 | + sourceCompatibility = JavaVersion.VERSION_21 |
| 94 | + targetCompatibility = JavaVersion.VERSION_21 |
| 95 | +} |
| 96 | + |
| 97 | +tasks.jar { |
| 98 | + inputs.property("archivesName", base.archivesName) |
| 99 | + |
| 100 | + from("LICENSE") { |
| 101 | + rename { "${it}_${inputs.properties["archivesName"]}" } |
65 | 102 | } |
66 | 103 | } |
| 104 | + |
| 105 | +fun <T> optionalProp(property: String, block: (String) -> T?): T? = |
| 106 | + findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block) |
| 107 | + |
0 commit comments