Skip to content

Commit 2ef86f5

Browse files
committed
update PGT
1 parent 0ae1efe commit 2ef86f5

File tree

6 files changed

+120
-75
lines changed

6 files changed

+120
-75
lines changed

build.gradle.kts

Lines changed: 101 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,146 @@
1+
@file:Suppress("UnstableApiUsage", "PropertyName")
2+
3+
import org.polyfrost.gradle.util.noServerRunConfigs
14
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
import cc.polyfrost.gradle.util.noServerRunConfigs
3-
import cc.polyfrost.gradle.util.setJvmDefault
45

6+
// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit
7+
// which we use to prepare the environment.
58
plugins {
69
kotlin("jvm")
7-
id("cc.polyfrost.multi-version")
8-
id("cc.polyfrost.defaults.repo")
9-
id("cc.polyfrost.defaults.java")
10-
id("cc.polyfrost.defaults.loom")
10+
id("org.polyfrost.multi-version")
11+
id("org.polyfrost.defaults.repo")
12+
id("org.polyfrost.defaults.java")
13+
id("org.polyfrost.defaults.loom")
1114
id("com.github.johnrengelman.shadow")
12-
id("net.kyori.blossom") version "1.3.0"
15+
id("net.kyori.blossom") version "1.3.1"
1316
id("signing")
1417
java
1518
}
1619

20+
// Gets the mod name, version and id from the `gradle.properties` file.
1721
val mod_name: String by project
1822
val mod_version: String by project
1923
val mod_id: String by project
24+
val mod_archives_name: String by project
2025

26+
// Sets up the variables for when we preprocess to other Minecraft versions.
2127
preprocess {
2228
vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0)
2329
}
2430

31+
// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
2532
blossom {
2633
replaceToken("@VER@", mod_version)
2734
replaceToken("@NAME@", mod_name)
2835
replaceToken("@ID@", mod_id)
2936
}
3037

38+
// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver!
3139
version = mod_version
40+
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
41+
// e.g. com.github.<your username> or com.<your domain>
3242
group = "dev.isxander"
43+
44+
// Sets the name of the output jar (the one you put in your mods folder and send to other people)
45+
// It outputs all versions of the mod into the `build` directory.
3346
base {
34-
archivesName.set("$mod_name-$platform")
47+
archivesName.set("$mod_archives_name-$platform")
3548
}
49+
50+
// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.
3651
loom {
52+
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
53+
// If you're developing a server-side mod, you can remove this line.
3754
noServerRunConfigs()
55+
56+
// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
3857
if (project.platform.isLegacyForge) {
39-
launchConfigs.named("client") {
40-
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
58+
runConfigs {
59+
"client" {
60+
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
61+
property("mixin.debug.export", "true")
62+
}
4163
}
4264
}
4365
}
44-
tasks.compileKotlin.setJvmDefault(if (platform.mcVersion >= 11400) "all" else "all-compatibility")
4566

67+
// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately.
4668
val shade: Configuration by configurations.creating {
4769
configurations.implementation.get().extendsFrom(this)
4870
}
4971

72+
// Configures the output directory for when building from the `src/resources` directory.
5073
sourceSets {
5174
main {
5275
output.setResourcesDir(java.classesDirectory)
5376
}
5477
}
5578

79+
// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
5680
repositories {
57-
maven("https://repo.polyfrost.cc/releases")
81+
maven("https://repo.polyfrost.org/releases")
5882
}
5983

84+
// Configures the libraries/dependencies for your mod.
6085
dependencies {
86+
// Adds the OneConfig library, so we can develop with it.
87+
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.1-alpha+")
88+
89+
modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.1.2")
90+
91+
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
6192
if (platform.isLegacyForge) {
62-
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0")
93+
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
6394
}
64-
compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+")
65-
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
6695
}
6796

68-
tasks.processResources {
69-
inputs.property("id", mod_id)
70-
inputs.property("name", mod_name)
71-
val java = if (project.platform.mcMinor >= 18) {
72-
17
73-
} else {
74-
if (project.platform.mcMinor == 17) 16 else 8
75-
}
76-
val compatLevel = "JAVA_${java}"
77-
inputs.property("java", java)
78-
inputs.property("java_level", compatLevel)
79-
inputs.property("version", mod_version)
80-
inputs.property("mcVersionStr", project.platform.mcVersionStr)
81-
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
82-
expand(
83-
mapOf(
84-
"id" to mod_id,
85-
"name" to mod_name,
86-
"java" to java,
87-
"java_level" to compatLevel,
88-
"version" to mod_version,
89-
"mcVersionStr" to project.platform.mcVersionStr
97+
tasks {
98+
// Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces
99+
// the mod id, name and version with the ones in `gradle.properties`
100+
processResources {
101+
inputs.property("id", mod_id)
102+
inputs.property("name", mod_name)
103+
val java = if (project.platform.mcMinor >= 18) {
104+
17 // If we are playing on version 1.18, set the java version to 17
105+
} else {
106+
// Else if we are playing on version 1.17, use java 16.
107+
if (project.platform.mcMinor == 17)
108+
16
109+
else
110+
8 // For all previous versions, we **need** java 8 (for Forge support).
111+
}
112+
val compatLevel = "JAVA_${java}"
113+
inputs.property("java", java)
114+
inputs.property("java_level", compatLevel)
115+
inputs.property("version", mod_version)
116+
inputs.property("mcVersionStr", project.platform.mcVersionStr)
117+
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
118+
expand(
119+
mapOf(
120+
"id" to mod_id,
121+
"name" to mod_name,
122+
"java" to java,
123+
"java_level" to compatLevel,
124+
"version" to mod_version,
125+
"mcVersionStr" to project.platform.mcVersionStr
126+
)
90127
)
91-
)
92-
}
93-
filesMatching("fabric.mod.json") {
94-
expand(
95-
mapOf(
96-
"id" to mod_id,
97-
"name" to mod_name,
98-
"java" to java,
99-
"java_level" to compatLevel,
100-
"version" to mod_version,
101-
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
128+
}
129+
filesMatching("fabric.mod.json") {
130+
expand(
131+
mapOf(
132+
"id" to mod_id,
133+
"name" to mod_name,
134+
"java" to java,
135+
"java_level" to compatLevel,
136+
"version" to mod_version,
137+
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
138+
)
102139
)
103-
)
140+
}
104141
}
105-
}
106142

107-
tasks {
143+
// Configures the resources to include if we are building for forge or fabric.
108144
withType(Jar::class.java) {
109145
if (project.platform.isFabric) {
110146
exclude("mcmod.info", "mods.toml")
@@ -117,24 +153,28 @@ tasks {
117153
}
118154
}
119155
}
156+
157+
// Configures our shadow/shade configuration, so we can
158+
// include some dependencies within our mod jar file.
120159
named<ShadowJar>("shadowJar") {
121-
archiveClassifier.set("dev")
160+
archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix.
122161
configurations = listOf(shade)
123162
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
124163
}
164+
125165
remapJar {
126-
input.set(shadowJar.get().archiveFile)
166+
inputFile.set(shadowJar.get().archiveFile)
127167
archiveClassifier.set("")
128168
}
169+
129170
jar {
130-
manifest {
131-
attributes(
132-
mapOf(
133-
"ModSide" to "CLIENT",
134-
"ForceLoadAsMod" to true,
135-
"TweakOrder" to "0",
136-
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker"
137-
)
171+
// Sets the jar manifest attributes.
172+
if (platform.isLegacyForge) {
173+
manifest.attributes += mapOf(
174+
"ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine.
175+
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
176+
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
177+
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
138178
)
139179
}
140180
dependsOn(shadowJar)

gradle.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
kotlin.code.style=official
22

3-
mod_version=3.2.0-beta2
3+
mod_version=3.1.2
44
mod_id=behindyouv3
55
mod_name=BehindYouV3
6+
mod_archives_name=BehindYouV3
67

8+
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
9+
polyfrost.defaults.loom=1
710
org.gradle.daemon=true
811
org.gradle.parallel=true
912
org.gradle.configureoncommand=true
1013
org.gradle.parallel.threads=4
11-
org.gradle.jvmargs=-Xmx3G
12-
polyfrost.defaults.loom=0
14+
org.gradle.jvmargs=-Xmx2G
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

root.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
plugins {
2-
kotlin("jvm") version "1.6.10" apply false
3-
id("net.kyori.blossom") version "1.3.0" apply false
2+
kotlin("jvm") version "1.8.22" apply false
3+
id("org.polyfrost.multi-version.root")
44
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
5-
id("cc.polyfrost.multi-version.root")
65
}
76

87
preprocess {
98
"1.12.2-forge"(11202, "srg") {
10-
"1.8.9-forge"(10809, "srg", file("versions/1.12.2-1.8.9.txt"))
9+
"1.8.9-forge"(10809, "srg")
1110
}
1211
}

settings.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1+
@file:Suppress("PropertyName")
2+
13
pluginManagement {
24
repositories {
35
gradlePluginPortal()
4-
maven("https://repo.polyfrost.cc/releases")
6+
mavenCentral()
7+
maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
58
}
69
plugins {
7-
val egtVersion = "0.1.28"
8-
id("cc.polyfrost.multi-version.root") version egtVersion
10+
val pgtVersion = "0.2.9" // Sets the default versions for Polyfrost Gradle Toolkit
11+
id("org.polyfrost.multi-version.root") version pgtVersion
912
}
1013
}
1114

1215
val mod_name: String by settings
1316

17+
// Configures the root project Gradle name based on the value in `gradle.properties`
1418
rootProject.name = mod_name
1519
rootProject.buildFileName = "root.gradle.kts"
1620

21+
// Adds all of our build target versions to the classpath if we need to add version-specific code.
1722
listOf(
18-
"1.8.9-forge",
19-
"1.12.2-forge",
23+
"1.8.9-forge", // Update this if you want to remove/add a version, along with `build.gradle.kts` and `root.gradle.kts`.
24+
"1.12.2-forge"
2025
).forEach { version ->
2126
include(":$version")
2227
project(":$version").apply {
2328
projectDir = file("versions/$version")
2429
buildFileName = "../../build.gradle.kts"
2530
}
26-
2731
}

versions/1.12.2-1.8.9.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)