Skip to content

Commit d091269

Browse files
committed
Bring up to speed with OneConfig example mod
1 parent c780811 commit d091269

File tree

4 files changed

+103
-48
lines changed

4 files changed

+103
-48
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Build Workflow
2+
3+
name: Build with Gradle
4+
5+
on:
6+
pull_request:
7+
workflow_dispatch:
8+
push:
9+
10+
concurrency:
11+
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
name: Build
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 10
25+
26+
- name: Set up JDK 17
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: 21
30+
distribution: temurin
31+
32+
- uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/.gradle/caches
36+
~/.gradle/wrapper
37+
**/loom-cache
38+
**/prebundled-jars
39+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
40+
restore-keys: |
41+
${{ runner.os }}-gradle-
42+
43+
- name: Chmod Gradle
44+
run: chmod +x ./gradlew
45+
46+
- name: Build
47+
run: ./gradlew build --no-daemon

build.gradle.kts

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
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")
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.
1416
}
1517

1618
toolkitLoomHelper {
17-
// Adds OneConfig to our project
18-
useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.43", mcData, "commands", "config-impl", "events", "hud", "internal", "ui")
19-
useDevAuth()
19+
useOneConfig {
20+
version = "1.0.0-alpha.47"
21+
loaderVersion = "1.1.0-alpha.34"
2022

21-
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
22-
// If you're developing a server-side mod, you can remove this line.
23+
usePolyMixin = true
24+
polyMixinVersion = "0.8.4+build.2"
25+
26+
applyLoaderTweaker = true
27+
28+
for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
29+
+module
30+
}
31+
}
32+
33+
// Turns off the server-side run configs, as we're building a client-sided mod.
2334
disableRunConfigs(GameSide.SERVER)
2435

25-
// Sets up our Mixin refmap naming
36+
// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
2637
if (!mcData.isNeoForge) {
2738
useMixinRefMap(modData.id)
2839
}
2940

30-
// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
31-
if (mcData.isLegacyForge) {
32-
useTweaker("org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker", GameSide.CLIENT)
33-
useForgeMixin(modData.id) // Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects.
41+
if (mcData.isForge) {
42+
// Configures the Mixin tweaker if we are building for Forge.
43+
useForgeMixin(modData.id)
3444
}
3545
}
3646

@@ -44,33 +54,15 @@ loom {
4454
}
4555
}
4656

47-
// Configures the output directory for when building from the `src/resources` directory.
48-
sourceSets {
49-
val dummy by creating
50-
main {
51-
compileClasspath += dummy.output
52-
output.setResourcesDir(java.classesDirectory)
53-
}
54-
}
55-
56-
// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
57-
repositories {
58-
maven("https://repo.polyfrost.org/releases")
59-
}
60-
61-
// Configures the libraries/dependencies for your mod.
6257
dependencies {
63-
when {
64-
mcData.isLegacyForge -> {
65-
compileOnly("org.polyfrost:polymixin:0.8.4+build.2")
66-
}
67-
68-
mcData.isFabric -> {
69-
modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}")
70-
71-
if (mcData.isLegacyFabric) {
72-
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
73-
}
58+
// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
59+
if (mcData.isFabric) {
60+
if (mcData.isLegacyFabric) {
61+
// 1.8.9 - 1.13
62+
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
63+
} else {
64+
// 1.16.5+
65+
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
7466
}
7567
}
7668
}

root.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ 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.12.2-fabric"(11202, "yarn") {
714
"1.12.2-forge"(11202, "srg") {
815
"1.8.9-forge"(10809, "srg", file("versions/1.12.2-forge+1.8.9-forge.txt")) {
916
"1.8.9-fabric"(10809, "yarn")
1017
}
1118
}
1219
}
13-
}
20+
21+
strictExtraMappings.set(true)
22+
}

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,32 +17,37 @@ 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",
3744
"1.8.9-fabric",
45+
"1.12.2-fabric",
3846
"1.12.2-forge",
39-
"1.12.2-fabric"
4047
).forEach { version ->
4148
include(":$version")
4249
project(":$version").apply {
4350
projectDir = file("versions/$version")
4451
buildFileName = "../../build.gradle.kts"
4552
}
46-
}
53+
}

0 commit comments

Comments
 (0)