Skip to content

Commit

Permalink
Separate Forge and NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
trainb0y committed Nov 21, 2023
1 parent 4cdfa58 commit 3b89519
Show file tree
Hide file tree
Showing 20 changed files with 499 additions and 12 deletions.
8 changes: 3 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias(libs.plugins.architectury.plugin)
alias(libs.plugins.architectury.loom) apply false
alias(libs.plugins.loom.vineflower) apply false

alias(libs.plugins.minotaur) apply false
alias(libs.plugins.cursegradle) apply false
Expand Down Expand Up @@ -81,10 +80,6 @@ allprojects {
}
}

subprojects {
apply(plugin = rootProject.libs.plugins.loom.vineflower.get().pluginId)
}

githubRelease {
token(findProperty("GITHUB_TOKEN")?.toString())

Expand All @@ -101,6 +96,8 @@ githubRelease {
{ findProject(":fabric")?.tasks?.get("remapSourcesJar")?.outputs?.files },
{ findProject(":forge")?.tasks?.get("remapJar")?.outputs?.files },
{ findProject(":forge")?.tasks?.get("remapSourcesJar")?.outputs?.files },
{ findProject(":neoforge")?.tasks?.get("remapJar")?.outputs?.files },
{ findProject(":neoforge")?.tasks?.get("remapSourcesJar")?.outputs?.files },
)
}

Expand All @@ -115,4 +112,5 @@ tasks.register("buildAll") {

findProject(":fabric")?.let { dependsOn(it.tasks["build"]) }
findProject(":forge")?.let { dependsOn(it.tasks["build"]) }
findProject(":neoforge")?.let { dependsOn(it.tasks["build"]) }
}
1 change: 1 addition & 0 deletions common/src/main/resources/yacl.mixins.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.isxander.yacl3.mixin",
"compatibilityLevel": "JAVA_17",
"injectors": {
Expand Down
3 changes: 1 addition & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ if (modrinthId.isNotEmpty()) {
versionType.set(if (isBeta) "beta" else "release")
uploadFile.set(tasks["remapJar"])
gameVersions.set(listOf("1.20.2"))
loaders.set(listOf("forge", "neoforge"))
loaders.set(listOf("forge"))
changelog.set(changelogText)
syncBodyFrom.set(rootProject.file("README.md").readText())
}
Expand All @@ -167,7 +167,6 @@ if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) {
releaseType = if (isBeta) "beta" else "release"
addGameVersion("1.20.2")
addGameVersion("Forge")
addGameVersion("NeoForge")
addGameVersion("Java 17")

changelog = changelogText
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ modDescription=YetAnotherConfigLib (yacl) is just that. A builder-based configur
modrinthId=yacl
curseforgeId=667299
githubProject=isXander/YetAnotherConfigLib

loaders=fabric,forge
loaders=fabric,forge,neoforge
10 changes: 7 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[versions]
# Plugins
architectury_loom = "1.3.+"
architectury_loom = "1.4.+"
architectury_plugin = "3.4.+"
shadow = "7.1.+"
loom_vineflower = "1.11.+"
minotaur = "2.7.+"
cursegradle = "2.+"
github_release = "2.4.+"
Expand All @@ -25,6 +24,9 @@ fabric_api = "0.90.4+1.20.2"
# Forge Dependencies
forge = "1.20.2-48.0.33"

# NeoForge Dependencies
neoforge = "20.2.59-beta"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" }
Expand All @@ -46,6 +48,9 @@ fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fab
# Forge Dependencies
forge = { module = "net.minecraftforge:forge", version.ref = "forge" }

# NeoForge Dependencies
neoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }

[bundles]
twelvemonkeys_imageio = [
"twelvemonkeys_imageio_core",
Expand All @@ -63,7 +68,6 @@ quilt_parsers = [
[plugins]
architectury_loom = { id = "dev.architectury.loom", version.ref = "architectury_loom" }
architectury_plugin = { id = "architectury-plugin", version.ref = "architectury_plugin" }
loom_vineflower = { id = "io.github.juuxel.loom-vineflower", version.ref = "loom_vineflower" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }

minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }
Expand Down
42 changes: 42 additions & 0 deletions neoforge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
197 changes: 197 additions & 0 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.libs

plugins {
alias(libs.plugins.architectury.loom)
alias(libs.plugins.shadow)
alias(libs.plugins.minotaur)
alias(libs.plugins.cursegradle)
}

architectury {
platformSetupLoomIde()
neoForge()
}

loom {
silentMojangMappingsLicense()

accessWidenerPath.set(project(":common").loom.accessWidenerPath)

neoForge {

}
}

repositories {
maven("https://maven.neoforged.net/releases/")
}

val common by configurations.registering
val shadowCommon by configurations.registering
configurations.compileClasspath.get().extendsFrom(common.get())
configurations["developmentNeoForge"].extendsFrom(common.get())

val minecraftVersion: String = libs.versions.minecraft.get()

dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
val qm = libs.versions.quilt.mappings.get()
if (qm != "0")
mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
neoForge(libs.neoforge)

libs.bundles.twelvemonkeys.imageio.let {
implementation(it)
include(it)
forgeRuntimeLibrary(it)
}
libs.bundles.quilt.parsers.let {
implementation(it)
include(it)
forgeRuntimeLibrary(it)
}

"common"(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
"shadowCommon"(project(path = ":common", configuration = "transformProductionNeoForge")) { isTransitive = false }
}

java {
withSourcesJar()
}

tasks {
processResources {
val modId: String by rootProject
val modName: String by rootProject
val modDescription: String by rootProject
val githubProject: String by rootProject
val majorNeoForge = libs.versions.neoforge.get().split('.').first()

inputs.property("id", modId)
inputs.property("group", project.group)
inputs.property("name", modName)
inputs.property("description", modDescription)
inputs.property("version", project.version)
inputs.property("github", githubProject)
inputs.property("major_neoforge", majorNeoForge)

filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta")) {
expand(
"id" to modId,
"group" to project.group,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubProject,
"major_neoforge" to majorNeoForge,
)
}
}

shadowJar {
exclude("fabric.mod.json")
exclude("architectury.common.json")

configurations = listOf(shadowCommon.get())
archiveClassifier.set("dev-shadow")
}

remapJar {
atAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
injectAccessWidener.set(true)
inputFile.set(shadowJar.get().archiveFile)
dependsOn(shadowJar)
archiveClassifier.set(null as String?)
from(rootProject.file("LICENSE"))
}

named<Jar>("sourcesJar") {
archiveClassifier.set("dev-sources")
val commonSources = project(":common").tasks.named<Jar>("sourcesJar")
dependsOn(commonSources)
from(commonSources.get().archiveFile.map { zipTree(it) })
}

remapSourcesJar {
archiveClassifier.set("sources")
}

jar {
archiveClassifier.set("dev")
}
}

components["java"].run {
if (this is AdhocComponentWithVariants) {
withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
}
}

val changelogText: String by ext
val isBeta: Boolean by ext

val modrinthId: String by project
if (modrinthId.isNotEmpty()) {
modrinth {
token.set(findProperty("modrinth.token")?.toString())
projectId.set(modrinthId)
versionName.set("${project.version} (NeoForge)")
versionNumber.set("${project.version}-neoforge")
versionType.set(if (isBeta) "beta" else "release")
uploadFile.set(tasks["remapJar"])
gameVersions.set(listOf("1.20.2"))
loaders.set(listOf("neoforge"))
changelog.set(changelogText)
syncBodyFrom.set(rootProject.file("README.md").readText())
}
}
rootProject.tasks["releaseMod"].dependsOn(tasks["modrinth"])

val curseforgeId: String by project
if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) {
curseforge {
apiKey = findProperty("curseforge.token")
project(closureOf<me.hypherionmc.cursegradle.CurseProject> {
mainArtifact(tasks["remapJar"], closureOf<me.hypherionmc.cursegradle.CurseArtifact> {
displayName = "[NeoForge] ${project.version}"
})

id = curseforgeId
releaseType = if (isBeta) "beta" else "release"
addGameVersion("1.20.2")
addGameVersion("NeoForge")
addGameVersion("Java 17")

changelog = changelogText
changelogType = "markdown"
})

options(closureOf<me.hypherionmc.cursegradle.Options> {
forgeGradleIntegration = false
fabricIntegration = false
})
}
}
rootProject.tasks["releaseMod"].dependsOn(tasks["curseforge"])

publishing {
publications {
create<MavenPublication>("neoforge") {
groupId = "dev.isxander.yacl"
artifactId = "yet-another-config-lib-neoforge"

from(components["java"])
}
}
}
tasks.findByPath("publishNeoforgePublicationToReleasesRepository")?.let {
rootProject.tasks["releaseMod"].dependsOn(it)
}
1 change: 1 addition & 0 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.isxander.yacl3.platform.neoforge;

import net.neoforged.fml.common.Mod;

@Mod("yet_another_config_lib_v3")
public class YACLNeoForgeEntrypoint {
public YACLNeoForgeEntrypoint() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.isxander.yacl3.platform.neoforge;

import dev.isxander.yacl3.platform.Env;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLPaths;

import java.nio.file.Path;

public class YACLPlatformImpl {
public static Env getEnvironment() {
return switch (FMLEnvironment.dist) {
case CLIENT -> Env.CLIENT;
case DEDICATED_SERVER -> Env.SERVER;
};
}

public static boolean isDevelopmentEnv() {
return !FMLEnvironment.production;
}

public static Path getConfigDir() {
return FMLPaths.CONFIGDIR.get();
}
}
Loading

0 comments on commit 3b89519

Please sign in to comment.