|
1 | 1 | @file:Suppress("UnstableApiUsage", "PropertyName") |
2 | 2 |
|
3 | 3 | import dev.deftu.gradle.utils.GameSide |
| 4 | +import dev.deftu.gradle.utils.MinecraftVersion |
4 | 5 |
|
5 | 6 | plugins { |
6 | 7 | java |
7 | 8 | kotlin("jvm") |
8 | | - id("dev.deftu.gradle.multiversion") |
9 | | - id("dev.deftu.gradle.tools") |
10 | | - id("dev.deftu.gradle.tools.resources") |
11 | | - id("dev.deftu.gradle.tools.bloom") |
12 | | - id("dev.deftu.gradle.tools.shadow") |
13 | | - id("dev.deftu.gradle.tools.minecraft.loom") |
14 | | -} |
15 | | - |
16 | | -// Sets up the variables for when we preprocess to other Minecraft versions. |
17 | | -preprocess { |
18 | | - vars.put("MODERN", if (mcData.version.minor >= 16) 1 else 0) |
| 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.ducks") // Creates a ducks source set, which allows us to use theoretical classes which may not exist at runtime (such as things which are in other mods). |
| 15 | + id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you. |
| 16 | + 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. |
19 | 17 | } |
20 | 18 |
|
21 | 19 | toolkitLoomHelper { |
22 | | - // Adds OneConfig to our project |
23 | | - useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.43", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") |
24 | | - useDevAuth() |
| 20 | + useOneConfig { |
| 21 | + version = "1.0.0-alpha.49" |
| 22 | + loaderVersion = "1.1.0-alpha.35" |
| 23 | + |
| 24 | + usePolyMixin = true |
| 25 | + polyMixinVersion = "0.8.4+build.2" |
| 26 | + |
| 27 | + applyLoaderTweaker = true |
| 28 | + |
| 29 | + for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) { |
| 30 | + +module |
| 31 | + } |
| 32 | + } |
25 | 33 |
|
26 | | - // Removes the server configs from IntelliJ IDEA, leaving only client runs. |
27 | | - // If you're developing a server-side mod, you can remove this line. |
| 34 | + // Turns off the server-side run configs, as we're building a client-sided mod. |
28 | 35 | disableRunConfigs(GameSide.SERVER) |
29 | 36 |
|
30 | | - // Sets up our Mixin refmap naming |
| 37 | + // Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes. |
31 | 38 | if (!mcData.isNeoForge) { |
32 | 39 | useMixinRefMap(modData.id) |
33 | 40 | } |
34 | 41 |
|
35 | | - // Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org) |
36 | | - if (mcData.isLegacyForge) { |
37 | | - useTweaker("org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker", GameSide.CLIENT) |
38 | | - useForgeMixin(modData.id) // Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects. |
| 42 | + if (mcData.isForge) { |
| 43 | + // Configures the Mixin tweaker if we are building for Forge. |
| 44 | + useForgeMixin(modData.id) |
39 | 45 | } |
40 | 46 | } |
41 | 47 |
|
42 | | -// Configures the output directory for when building from the `src/resources` directory. |
43 | | -sourceSets { |
44 | | - val dummy by creating |
45 | | - main { |
46 | | - dummy.compileClasspath += compileClasspath |
47 | | - compileClasspath += dummy.output |
48 | | - output.setResourcesDir(java.classesDirectory) |
49 | | - } |
50 | | -} |
51 | | - |
52 | | -// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. |
53 | | -repositories { |
54 | | - maven("https://repo.polyfrost.org/releases") |
55 | | -} |
56 | | - |
57 | | -// Configures the libraries/dependencies for your mod. |
58 | 48 | dependencies { |
59 | | - // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier. |
60 | | - if (mcData.isLegacyForge) { |
61 | | - compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") |
62 | | - } else if (mcData.isFabric) { |
63 | | - modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}") |
| 49 | + // Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful). |
| 50 | + if (mcData.isFabric) { |
| 51 | + if (mcData.isLegacyFabric) { |
| 52 | + // 1.8.9 - 1.13 |
| 53 | + modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}") |
| 54 | + } else { |
| 55 | + // 1.16.5+ |
| 56 | + modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}") |
| 57 | + } |
64 | 58 | } |
65 | 59 | } |
0 commit comments