Skip to content

Commit a7553b0

Browse files
committed
chore: bump versions, add better documentation
Signed-off-by: Pauline <git@ethanlibs.co>
1 parent 6d8a012 commit a7553b0

File tree

12 files changed

+247
-137
lines changed

12 files changed

+247
-137
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ Example mod implementing OneConfig.
55

66
- Copy the template either by using GitHub's "Use this template" feature or downloading the repo manually.
77
- **Remove the license named "LICENSE-TEMPLATE" and choose a new one.**
8-
- Refactor the template (specifically, the modid, version and name in the gradle.properties and most of the class names) to a different name.
8+
- Refactor the template (specifically, the modid, version and name in the gradle.properties and most of the class names)
9+
to a different name.
10+
- Have fun modding! :D

build.gradle.kts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22
import cc.polyfrost.gradle.util.noServerRunConfigs
33

4+
// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit which we use to prepare the environment.
45
plugins {
56
kotlin("jvm")
67
id("cc.polyfrost.multi-version")
@@ -13,72 +14,95 @@ plugins {
1314
java
1415
}
1516

17+
// Gets the mod name, version and id from the `gradle.properties` file.
1618
val mod_name: String by project
1719
val mod_version: String by project
1820
val mod_id: String by project
1921

22+
// Sets up the variables for when we preprocess to other Minecraft versions.
2023
preprocess {
2124
vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0)
2225
}
2326

27+
// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
2428
blossom {
2529
replaceToken("@VER@", mod_version)
2630
replaceToken("@NAME@", mod_name)
2731
replaceToken("@ID@", mod_id)
2832
}
2933

34+
// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver!
3035
version = mod_version
36+
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
37+
// e.g. com.github.<your username> or com.<your domain>
3138
group = "cc.polyfrost"
39+
// Sets the name of the output jar (the one you put in your mods folder and send to other people)
40+
// It outputs all versions of the mod into the `build` directory.
3241
base {
3342
archivesName.set("$mod_id-$platform")
3443
}
3544

45+
// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.
3646
loom {
47+
// Removes the server configs from IntelliJ IDEA, since we aren't developing a server mod.
3748
noServerRunConfigs()
49+
// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.cc)
3850
if (project.platform.isLegacyForge) {
3951
launchConfigs.named("client") {
4052
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
41-
property("mixin.debug.export", "true")
53+
property(
54+
"mixin.debug.export",
55+
"true"
56+
) // This is enabled so OneConfig can read our Mixins and automatically apply them.
4257
}
4358
}
59+
// Configures the mixins if we are building for forge. (Useful for when we are dealing with cross-platform projects.
4460
if (project.platform.isForge) {
4561
forge {
4662
mixinConfig("mixins.${mod_id}.json")
4763
}
4864
}
65+
// Configures the name of the mixin "refmap" using an experimental loom api. You can ignore this warning.
4966
mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json")
5067
}
5168

69+
// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately.
5270
val shade: Configuration by configurations.creating {
5371
configurations.implementation.get().extendsFrom(this)
5472
}
5573

74+
// Configures the output directory for when building from the `src/resources` directory.
5675
sourceSets {
5776
main {
5877
output.setResourcesDir(java.classesDirectory)
5978
}
6079
}
6180

81+
// Adds the Polyfrost maven repository so we can get the libraries necessary to develop the mod.
6282
repositories {
6383
maven("https://repo.polyfrost.cc/releases")
6484
}
6585

86+
// Configures the libraries/dependencies for your mod.
6687
dependencies {
67-
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+")
88+
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+") // Adds the OneConfig library, so we can develop with it.
6889

90+
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
6991
if (platform.isLegacyForge) {
7092
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
7193
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
7294
}
7395
}
7496

97+
// Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces the mod id, name and version with the ones in `gradle.properties`
7598
tasks.processResources {
7699
inputs.property("id", mod_id)
77100
inputs.property("name", mod_name)
78101
val java = if (project.platform.mcMinor >= 18) {
79-
17
102+
17 // If we are playing on version 1.18, set the java version to 17
80103
} else {
81-
if (project.platform.mcMinor == 17) 16 else 8
104+
// Else if we are playing on version 1.17, use java 16.
105+
if (project.platform.mcMinor == 17) 16 else 8 // For all previous versions, java version 8 is okay.
82106
}
83107
val compatLevel = "JAVA_${java}"
84108
inputs.property("java", java)
@@ -112,6 +136,7 @@ tasks.processResources {
112136
}
113137

114138
tasks {
139+
// Configures the resources to include if we are building for forge or fabric.
115140
withType(Jar::class.java) {
116141
if (project.platform.isFabric) {
117142
exclude("mcmod.info", "mods.toml")
@@ -124,24 +149,26 @@ tasks {
124149
}
125150
}
126151
}
152+
// Configures our shadow/shade configuration, so we can include the OneConfig launch wrapper with our mod.
127153
named<ShadowJar>("shadowJar") {
128-
archiveClassifier.set("dev")
154+
archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix.
129155
configurations = listOf(shade)
130156
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
131157
}
132158
remapJar {
133159
input.set(shadowJar.get().archiveFile)
134160
archiveClassifier.set("")
135161
}
162+
// Sets the jar manifest attributes.
136163
jar {
137164
manifest {
138165
attributes(
139166
mapOf(
140-
"ModSide" to "CLIENT",
141-
"ForceLoadAsMod" to true,
142-
"TweakOrder" to "0",
143-
"MixinConfigs" to "mixin.${mod_id}.json",
144-
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker"
167+
"ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine.
168+
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
169+
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
170+
"MixinConfigs" to "mixin.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
171+
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
145172
)
146173
)
147174
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.
2+
# Sets the name of your mod.
13
mod_name=ExampleMod
4+
# Sets the id of your mod that mod loaders use to recognize it.
25
mod_id=examplemod
6+
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
37
mod_version=1.0.0
8+
# Sets the name of the jar file that you put in your mods folder.
49
mod_archives_name=ExampleMod
10+
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
511
loom.platform=forge
612
polyfrost.defaults.loom=1
713
org.gradle.daemon=true

gradle/wrapper/gradle-wrapper.jar

1.99 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)