Skip to content

Commit df7f033

Browse files
committed
Port to 1.20.4 (NeoForge-only)
1 parent 6b40e9b commit df7f033

File tree

235 files changed

+1077
-3211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+1077
-3211
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- name: Set up Gradle
2020
uses: gradle/gradle-build-action@v2
2121
- name: Generate data
22-
run: ./gradlew downloadAssets runData
22+
run: ./gradlew runData
2323
- name: Build
2424
run: ./gradlew build

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Gradle
2323
uses: gradle/gradle-build-action@v2
2424
- name: Generate data
25-
run: ./gradlew downloadAssets runData
25+
run: ./gradlew runData
2626
- name: Build release files
2727
id: build
2828
env:

build.gradle.kts

+100-222
Original file line numberDiff line numberDiff line change
@@ -1,260 +1,138 @@
1-
import net.fabricmc.loom.api.LoomGradleExtensionAPI
2-
import net.fabricmc.loom.task.RemapJarTask
3-
41
plugins {
5-
`kotlin-dsl`
6-
java
7-
`maven-publish`
8-
alias(libs.plugins.loom) apply false
9-
alias(libs.plugins.architectury)
10-
alias(libs.plugins.shadow)
2+
alias(libs.plugins.neogradle)
113
alias(libs.plugins.spotless)
124
}
135

14-
val modId: String by project
15-
val modVersion = (System.getenv("MEGA_VERSION") ?: "v0.0.0").substring(1)
16-
val minecraftVersion = libs.versions.minecraft.get()
6+
val modId = "megacells"
177

18-
val platforms by extra {
19-
property("enabledPlatforms").toString().split(',')
20-
}
8+
base.archivesName = modId
9+
version = System.getenv("MEGA_VERSION") ?: "0.0.0"
10+
group = "gripe.90"
2111

22-
tasks {
23-
register("releaseInfo") {
24-
doLast {
25-
val output = System.getenv("GITHUB_OUTPUT")
12+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
2613

27-
if (!output.isNullOrEmpty()) {
28-
val outputFile = File(output)
29-
outputFile.appendText("MOD_VERSION=$modVersion\n")
30-
outputFile.appendText("MINECRAFT_VERSION=$minecraftVersion\n")
31-
}
14+
repositories {
15+
mavenLocal()
16+
mavenCentral()
17+
18+
maven {
19+
name = "ModMaven (K4U-NL)"
20+
url = uri("https://modmaven.dev/")
21+
content {
22+
includeGroup("appeng")
3223
}
3324
}
3425

35-
withType<Jar> {
36-
enabled = false
26+
maven {
27+
name = "Modrinth Maven"
28+
url = uri("https://api.modrinth.com/maven")
29+
content {
30+
includeGroup("maven.modrinth")
31+
}
3732
}
3833
}
3934

40-
subprojects {
41-
apply(plugin = "java")
42-
apply(plugin = rootProject.libs.plugins.architectury.get().pluginId)
43-
apply(plugin = rootProject.libs.plugins.loom.get().pluginId)
44-
apply(plugin = rootProject.libs.plugins.spotless.get().pluginId)
45-
46-
base.archivesName.set("$modId-${project.name}")
47-
version = "$modVersion-$minecraftVersion"
48-
group = property("mavenGroup").toString()
49-
50-
val javaVersion: String by project
51-
52-
java {
53-
sourceCompatibility = JavaVersion.valueOf("VERSION_$javaVersion")
54-
targetCompatibility = JavaVersion.valueOf("VERSION_$javaVersion")
35+
dependencies {
36+
implementation(libs.neoforge)
37+
implementation(libs.ae2)
5538

56-
withSourcesJar()
57-
}
39+
implementation(libs.ae2wtlib)
40+
runtimeOnly(libs.curios)
41+
}
5842

59-
architectury {
60-
minecraft = minecraftVersion
61-
injectInjectables = false
43+
sourceSets {
44+
main {
45+
resources.srcDir(file("src/generated/resources"))
6246
}
63-
64-
configure<LoomGradleExtensionAPI> {
65-
silentMojangMappingsLicense()
66-
67-
@Suppress("UnstableApiUsage")
68-
mixin.defaultRefmapName.set("$modId.refmap.json")
47+
48+
create("data") {
49+
val main = main.get()
50+
compileClasspath += main.compileClasspath + main.output
51+
runtimeClasspath += main.runtimeClasspath + main.output
6952
}
53+
}
7054

71-
repositories {
72-
mavenLocal()
73-
mavenCentral()
74-
75-
maven {
76-
name = "ModMaven (K4U-NL)"
77-
url = uri("https://modmaven.dev/")
78-
content {
79-
includeGroup("appeng")
80-
includeGroup("mezz.jei")
81-
}
82-
}
83-
84-
maven {
85-
name = "BlameJared"
86-
url = uri("https://maven.blamejared.com")
87-
content {
88-
includeGroup("vazkii.botania")
89-
includeGroup("vazkii.patchouli")
90-
}
91-
}
92-
93-
maven {
94-
name = "Modrinth Maven"
95-
url = uri("https://api.modrinth.com/maven")
96-
content {
97-
includeGroup("maven.modrinth")
98-
}
99-
}
55+
runs {
56+
configureEach {
57+
workingDirectory(file("run"))
58+
systemProperty("forge.logging.console.level", "info")
59+
60+
modSource(sourceSets.main.get())
10061
}
101-
102-
dependencies {
103-
"minecraft"(rootProject.libs.minecraft)
104-
"mappings"(project.extensions.getByName<LoomGradleExtensionAPI>("loom").officialMojangMappings())
62+
63+
create("client")
64+
create("server")
65+
66+
create("data") {
67+
programArguments.addAll(
68+
"--mod", modId,
69+
"--all",
70+
"--output", file("src/generated/resources/").absolutePath,
71+
"--existing", file("src/main/resources/").absolutePath)
72+
73+
modSource(sourceSets.getByName("data"))
10574
}
75+
}
10676

107-
sourceSets {
108-
create("data") {
109-
val main = sourceSets.main.get()
110-
compileClasspath += main.compileClasspath + main.output
111-
runtimeClasspath += main.runtimeClasspath + main.output
77+
tasks {
78+
jar {
79+
from(rootProject.file("LICENSE")) {
80+
rename { "${it}_$modId" }
11281
}
11382
}
11483

115-
tasks {
116-
jar {
117-
from(rootProject.file("LICENSE")) {
118-
rename { "${it}_$modId"}
119-
}
120-
}
121-
122-
withType<JavaCompile> {
123-
options.encoding = "UTF-8"
124-
options.release.set(javaVersion.toInt())
125-
}
84+
withType<JavaCompile> {
85+
options.encoding = "UTF-8"
12686
}
127-
128-
spotless {
129-
kotlinGradle {
130-
target("*.kts")
131-
diktat()
132-
}
133-
134-
java {
135-
target("src/**/java/**/*.java")
136-
endWithNewline()
137-
indentWithSpaces(4)
138-
removeUnusedImports()
139-
palantirJavaFormat()
140-
importOrderFile(rootProject.file("codeformat/mega.importorder"))
141-
142-
// courtesy of diffplug/spotless#240
143-
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
144-
custom("noWildcardImports") {
145-
if (it.contains("*;\n")) {
146-
throw Error("No wildcard imports allowed")
147-
}
148-
149-
it
150-
}
151-
152-
bumpThisNumberIfACustomStepChanges(1)
153-
}
154-
155-
json {
156-
target("src/**/resources/**/*.json")
157-
targetExclude("src/generated/resources/**")
158-
biome()
159-
indentWithSpaces(2)
160-
endWithNewline()
87+
88+
processResources {
89+
exclude("**/.cache")
90+
91+
val props = mapOf(
92+
"version" to version,
93+
"ae2Version" to libs.versions.ae2.get(),
94+
"ae2VersionEnd" to libs.versions.ae2.get().substringBefore('.').toInt() + 1,
95+
)
96+
97+
inputs.properties(props)
98+
filesMatching("META-INF/mods.toml") {
99+
expand(props)
161100
}
162101
}
163102
}
164103

165-
for (platform in platforms) {
166-
project(":$platform") {
167-
apply(plugin = rootProject.libs.plugins.shadow.get().pluginId)
168-
169-
architectury {
170-
platformSetupLoomIde()
171-
loader(platform)
172-
}
173-
174-
fun capitalise(str: String): String {
175-
return str.replaceFirstChar {
176-
if (it.isLowerCase()) {
177-
it.titlecase()
178-
} else {
179-
it.toString()
180-
}
181-
}
182-
}
183-
184-
val common: Configuration by configurations.creating
185-
val shadowCommon: Configuration by configurations.creating
186-
187-
@Suppress("UnstableApiUsage")
188-
configurations {
189-
compileClasspath { extendsFrom(common) }
190-
runtimeClasspath { extendsFrom(common) }
191-
getByName("development${capitalise(platform)}") { extendsFrom(common) }
192-
}
193-
194-
dependencies {
195-
common(project(path = ":common", configuration = "namedElements")) {
196-
isTransitive = false
197-
}
104+
spotless {
105+
kotlinGradle {
106+
target("*.kts")
107+
diktat()
108+
}
198109

199-
shadowCommon(project(path = ":common", configuration = "transformProduction${capitalise(platform)}")) {
200-
isTransitive = false
201-
}
202-
}
110+
java {
111+
target("/src/**/java/**/*.java")
112+
endWithNewline()
113+
indentWithSpaces(4)
114+
removeUnusedImports()
115+
palantirJavaFormat()
116+
importOrderFile(file("mega.importorder"))
203117

204-
sourceSets {
205-
main {
206-
resources {
207-
srcDir(file("src/generated/resources"))
208-
exclude("**/.cache")
209-
}
118+
// courtesy of diffplug/spotless#240
119+
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
120+
custom("noWildcardImports") {
121+
if (it.contains("*;\n")) {
122+
throw Error("No wildcard imports allowed")
210123
}
211124

212-
getByName("data") {
213-
val commonData = project(":common").sourceSets.getByName("data")
214-
compileClasspath += commonData.output
215-
runtimeClasspath += commonData.output
216-
}
125+
it
217126
}
218127

219-
tasks {
220-
processResources {
221-
val commonProps by extra { mapOf(
222-
"version" to project.version,
223-
"minecraftVersion" to minecraftVersion,
224-
"ae2Version" to rootProject.libs.versions.ae2.get(),
225-
"ae2wtVersion" to rootProject.libs.versions.ae2wtlib.get(),
226-
"appbotVersion" to rootProject.libs.versions.appbot.get())
227-
}
228-
229-
inputs.properties(commonProps)
230-
}
231-
232-
shadowJar {
233-
exclude("architectury.common.json")
234-
configurations = listOf(shadowCommon)
235-
archiveClassifier.set("dev-shadow")
236-
}
237-
238-
withType<RemapJarTask> {
239-
inputFile.set(shadowJar.get().archiveFile)
240-
dependsOn(shadowJar)
241-
archiveClassifier.set(null as String?)
242-
}
243-
244-
jar {
245-
archiveClassifier.set("dev")
246-
}
247-
248-
getByName<Jar>("sourcesJar") {
249-
val commonSources = project(":common").tasks.getByName<Jar>("sourcesJar")
250-
dependsOn(commonSources)
251-
from(commonSources.archiveFile.map { zipTree(it) })
252-
}
253-
}
128+
bumpThisNumberIfACustomStepChanges(1)
129+
}
254130

255-
val javaComponent = components["java"] as AdhocComponentWithVariants
256-
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
257-
skip()
258-
}
131+
json {
132+
target("src/**/resources/**/*.json")
133+
targetExclude("src/generated/resources/**")
134+
biome()
135+
indentWithSpaces(2)
136+
endWithNewline()
259137
}
260138
}

common/build.gradle.kts

-13
This file was deleted.

0 commit comments

Comments
 (0)