generated from isXander/FabricModTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
499 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loom.platform=neoforge |
11 changes: 11 additions & 0 deletions
11
neoforge/src/main/java/dev/isxander/yacl3/platform/neoforge/YACLNeoForgeEntrypoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
neoforge/src/main/java/dev/isxander/yacl3/platform/neoforge/YACLPlatformImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.