Skip to content

Commit 40eb11c

Browse files
committed
Bring up to speed with the OneConfig example mod
1 parent bd71ad9 commit 40eb11c

File tree

4 files changed

+62
-52
lines changed

4 files changed

+62
-52
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
2323
with:
2424
fetch-depth: 10
2525

2626
- name: Set up JDK 17
27-
uses: actions/setup-java@v2
27+
uses: actions/setup-java@v4
2828
with:
29-
java-version: 17
29+
java-version: 21
3030
distribution: temurin
3131

32-
- uses: actions/cache@v2
32+
- uses: actions/cache@v4
3333
with:
3434
path: |
3535
~/.gradle/caches

build.gradle.kts

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,59 @@
11
@file:Suppress("UnstableApiUsage", "PropertyName")
22

33
import dev.deftu.gradle.utils.GameSide
4+
import dev.deftu.gradle.utils.MinecraftVersion
45

56
plugins {
67
java
78
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.
1917
}
2018

2119
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+
}
2533

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.
2835
disableRunConfigs(GameSide.SERVER)
2936

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.
3138
if (!mcData.isNeoForge) {
3239
useMixinRefMap(modData.id)
3340
}
3441

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)
3945
}
4046
}
4147

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.
5848
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+
}
6458
}
6559
}

root.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ plugins {
33
}
44

55
preprocess {
6+
// Adding new versions/loaders can be done like so:
7+
// For each version, we add a new wrapper around the last from highest to lowest.
8+
// Each mod loader needs to link up to the previous version's mod loader so that the mappings can be processed from the previous version.
9+
// "1.12.2-forge"(11202, "srg") {
10+
// "1.8.9-forge"(10809, "srg")
11+
// }
12+
613
"1.8.9-forge"(10809, "srg") {
714
"1.8.9-fabric"(10809, "yarn")
815
}
9-
}
16+
17+
strictExtraMappings.set(true)
18+
}

settings.gradle.kts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
@file:Suppress("PropertyName")
2+
13
import groovy.lang.MissingPropertyException
24

35
pluginManagement {
46
repositories {
5-
// Repositories
7+
// Releases
68
maven("https://maven.deftu.dev/releases")
79
maven("https://maven.fabricmc.net")
810
maven("https://maven.architectury.dev/")
@@ -15,30 +17,35 @@ pluginManagement {
1517
maven("https://maven.deftu.dev/snapshots")
1618
mavenLocal()
1719

18-
// Default repositories
20+
// Default
1921
gradlePluginPortal()
2022
mavenCentral()
2123
}
2224

2325
plugins {
2426
kotlin("jvm") version("2.0.0")
25-
id("dev.deftu.gradle.multiversion-root") version("2.13.0")
27+
id("dev.deftu.gradle.multiversion-root") version("2.18.1")
2628
}
2729
}
2830

2931
val projectName: String = extra["mod.name"]?.toString()
3032
?: throw MissingPropertyException("mod.name has not been set.")
33+
34+
// Configures the root project Gradle name based on the value in `gradle.properties`
3135
rootProject.name = projectName
3236
rootProject.buildFileName = "root.gradle.kts"
3337

3438
// Adds all of our build target versions to the classpath if we need to add version-specific code.
39+
// Update this list if you want to remove/add a version and/or mod loader.
40+
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
41+
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
3542
listOf(
3643
"1.8.9-forge",
37-
"1.8.9-fabric"
44+
"1.8.9-fabric",
3845
).forEach { version ->
3946
include(":$version")
4047
project(":$version").apply {
4148
projectDir = file("versions/$version")
4249
buildFileName = "../../build.gradle.kts"
4350
}
44-
}
51+
}

0 commit comments

Comments
 (0)