Skip to content

Commit

Permalink
Add support for NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Dec 23, 2023
1 parent 8dff97e commit 8934b00
Show file tree
Hide file tree
Showing 21 changed files with 224 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build
# other
eclipse
run
runs
secrets.json
changelog.md
*.launch
Expand Down
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import java.util.*

plugins {
`java-library`
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
}

version = GMUtils.updatingVersion(Versions.MOD)

tasks.create("postDiscord") {

val taskName = "publishCurseForge"
dependsOn(":fabric:${taskName}", ":forge:${taskName}", ":neoforge:${taskName}")
doLast {
try {

Expand All @@ -30,13 +32,13 @@ tasks.create("postDiscord") {
val embed = Embed()
val downloadSources = StringJoiner("\n")

mapOf(Pair("fabric", "<:fabric:932163720568782878>"), Pair("forge", "<:forge:932163698003443804>"))
mapOf(Pair("fabric", "<:fabric:932163720568782878>"), Pair("forge", "<:forge:932163698003443804>"), Pair("neoforge", "<:neoforged:1184738260371644446>"))
.filter {
project(":${it.key}").ext.has("curse_file_url")
}.map { "${it.value} [${it.key.capitalize(Locale.ENGLISH)}](${project(":${it.key}").ext.get("curse_file_url")})" }
.forEach { downloadSources.add(it) }

listOf("common", "fabric", "forge")
listOf("common", "fabric", "forge", "neoforge")
.map { project(":${it}") }
.map { "<:maven:932165250738970634> `\"${it.group}:${it.base.archivesName.get()}:${it.version}\"`" }
.forEach { downloadSources.add(it) }
Expand All @@ -49,7 +51,7 @@ tasks.create("postDiscord") {
embed.addField("Download", downloadString, false)
}

embed.addField("Changelog", GMUtils.smallChangelog(project, Properties.GIT_REPO), false)
embed.addField("Changelog", GMUtils.smallChangelog(project, Properties.GIT_REPO).take(1000), false)

embed.color = 0xF16436
message.addEmbed(embed)
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
dependencies {
gradleApi()
implementation(group = "com.blamejared", name = "gradle-mod-utils", version = "1.0.3")
implementation(group = "net.darkhax.curseforgegradle", name = "CurseForgeGradle", version = "1.0.10")
implementation(group = "net.darkhax.curseforgegradle", name = "CurseForgeGradle", version = "1.1.16")
implementation(group = "com.modrinth.minotaur", name = "Minotaur", version = "2.+")
implementation(group = "com.diluv.schoomp", name= "Schoomp", version="1.2.6")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class DefaultPlugin : Plugin<Project> {
applyIdeaPlugin(project)
applyDependencies(project)
applyMavenPlugin(project)
project.plugins.withType()
}

private fun setupDefaults(project: Project) {
Expand All @@ -58,9 +57,6 @@ class DefaultPlugin : Plugin<Project> {
this.add(this.maven("https://maven.blamejared.com/") {
name = "BlameJared"
})
this.add(this.maven("https://maven.parchmentmc.org/") {
name = "ParchmentMC"
})
}

}
Expand Down Expand Up @@ -104,17 +100,32 @@ class DefaultPlugin : Plugin<Project> {
}

withType<ProcessResources> {
outputs.upToDateWhen { false }
inputs.property("version", project.version)
filesMatching("*.mixins.json") {
if (project.name == "fabric") {
expand("refmap_target" to "${project.extensions.getByType(BasePluginExtension::class.java).archivesName.get()}-")
} else {
expand("refmap_target" to "${Properties.MODID}.")
}
}
filesMatching("fabric.mod.json") {
expand("version" to project.version)
val properties = mapOf(
"version" to project.version,
"MOD" to Versions.MOD,
"JAVA" to Versions.JAVA,
"MINECRAFT" to Versions.MINECRAFT,
"FABRIC_LOADER" to Versions.FABRIC_LOADER,
"FABRIC" to Versions.FABRIC,
"FORGE" to Versions.FORGE,
"FORGE_LOADER" to Versions.FORGE_LOADER,
"NEO_FORGE" to Versions.NEO_FORGE,
"NEO_FORGE_LOADER" to Versions.NEO_FORGE_LOADER,
"GROUP" to Properties.GROUP,
"NAME" to Properties.NAME,
"AUTHOR" to Properties.AUTHOR,
"MODID" to Properties.MODID,
"AVATAR" to Properties.AVATAR,
"CURSE_PROJECT_ID" to Properties.CURSE_PROJECT_ID,
"CURSE_HOMEPAGE" to Properties.CURSE_HOMEPAGE,
"MODRINTH_PROJECT_ID" to Properties.MODRINTH_PROJECT_ID,
"GIT_REPO" to Properties.GIT_REPO,
"DESCRIPTION" to Properties.DESCRIPTION,
"ITEM_ICON" to Properties.ITEM_ICON,
)
inputs.properties(properties)
filesMatching(setOf("fabric.mod.json", "META-INF/mods.toml", "pack.mcmeta")) {
expand(properties)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.blamejared.gradle.mod.utils.GradleModUtilsPlugin
import com.blamejared.gradle.mod.utils.extensions.VersionTrackerExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
Expand All @@ -26,15 +27,15 @@ class LoaderPlugin : Plugin<Project> {
val commonJava = commonJava(project)

project.tasks {
withType<ProcessResources> {
withType<ProcessResources>().matching { notNeoTask(it) }.configureEach {
from(commonJava.sourceSets.getByName("main").resources)
}

withType<JavaCompile> {
withType<JavaCompile>().matching { notNeoTask(it) }.configureEach {
source(commonJava(project).sourceSets.getByName("main").allSource)
}

withType<Javadoc> {
withType<Javadoc>().matching { notNeoTask(it) }.configureEach {
source(commonJava(project).sourceSets.getByName("main").allJava)
}

Expand Down Expand Up @@ -66,6 +67,10 @@ class LoaderPlugin : Plugin<Project> {
}
}

private fun notNeoTask(task: Task): Boolean {
return !task.name.startsWith("neo")
}

private fun notCommon(project: Project): Boolean {
return !project.name.equals("common")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package com.blamejared.ambientenvironment.gradle
object Properties {
const val GROUP = "com.blamejared.ambientenvironment"
const val NAME = "AmbientEnvironment"
const val AUTHOR = "Jared"
const val AUTHOR = "Jaredlll08"
const val MODID = "ambientenvironment"
const val AVATAR = "https://media.forgecdn.net/avatars/201/25/636917476563554470.png"
const val CURSE_PROJECT_ID = "320163"
const val CURSE_HOMEPAGE = "https://www.curseforge.com/minecraft/mc-mods/ambient-environment"
const val MODRINTH_PROJECT_ID = "DyTvM1dv"
const val GIT_REPO = "https://github.com/jaredlll08/Ambient-Environment"
const val DESCRIPTION = "Adds more ambiance to the game."
const val ITEM_ICON = "minecraft:grass_block"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ object Versions {
const val MOD = "12.0.0"
const val JAVA = "17"
const val MINECRAFT = "1.20.2"
const val FABRIC_LOADER = "0.14.22"
const val FABRIC = "0.89.2+1.20.2"
const val FORGE = "48.0.1"
const val FABRIC_LOADER = "0.14.21"
const val FORGE_LOADER = "[41,)"
const val NEO_FORGE = "20.2.86"
const val NEO_FORGE_LOADER= "[1,)"
}
2 changes: 1 addition & 1 deletion common/src/main/resources/ambientenvironment.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minVersion": "0.8",
"package": "com.blamejared.ambientenvironment.mixin",
"compatibilityLevel": "JAVA_17",
"refmap": "${refmap_target}refmap.json",
"refmap": "ambientenvironment.refmap.json",
"client": [
"BiomeColorsAccessor"
],
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"description": "${NAME}",
"pack_format": 6
}
}
16 changes: 9 additions & 7 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.darkhax.curseforgegradle.Constants as CFG_Constants

plugins {
id("fabric-loom") version "1.2-SNAPSHOT"
id("fabric-loom") version "1.4-SNAPSHOT"
id("com.blamejared.ambientenvironment.default")
id("com.blamejared.ambientenvironment.loader")
id("com.modrinth.minotaur")
}

dependencies {
minecraft("com.mojang:minecraft:${Versions.MINECRAFT}")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.18.1:2021.12.19@zip")
})
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${Versions.FABRIC_LOADER}")
implementation(project(":common"))
}

loom {
mixin {
defaultRefmapName.set("${Properties.MODID}.refmap.json")
}
runs {
named("client") {
client()
Expand All @@ -33,15 +33,15 @@ loom {
}

tasks.create<TaskPublishCurseForge>("publishCurseForge") {
dependsOn(tasks.remapJar)
apiToken = GMUtils.locateProperty(project, "curseforgeApiToken")

val mainFile = upload(Properties.CURSE_PROJECT_ID, file("${project.buildDir}/libs/${base.archivesName.get()}-$version.jar"))
val mainFile = upload(Properties.CURSE_PROJECT_ID, file("${project.layout.buildDirectory}/libs/${base.archivesName.get()}-$version.jar"))
mainFile.changelogType = "markdown"
mainFile.changelog = GMUtils.smallChangelog(project, Properties.GIT_REPO)
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_RELEASE
mainFile.addJavaVersion("Java ${Versions.JAVA}")
mainFile.addGameVersion(Versions.MINECRAFT)
mainFile.addRequirement("fabric-api")

doLast {
project.ext.set("curse_file_url", "${Properties.CURSE_HOMEPAGE}/files/${mainFile.curseFileId}")
Expand All @@ -54,5 +54,7 @@ modrinth {
changelog.set(GMUtils.smallChangelog(project, Properties.GIT_REPO))
versionName.set("Fabric-${Versions.MINECRAFT}-$version")
versionType.set("release")
gameVersions.set(listOf(Versions.MINECRAFT))
uploadFile.set(tasks.remapJar.get())
}
tasks.modrinth.get().dependsOn(tasks.remapJar)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
],
"injectors": {
"defaultRequire": 1
}
},
"refmap": "ambientenvironment.refmap.json"
}
26 changes: 14 additions & 12 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
{
"schemaVersion": 1,
"id": "ambientenvironment",
"id": "${MODID}",
"name": "${NAME}",
"version": "${version}",
"name": "Ambient Environment",
"description": "Adds more ambiance to the game",
"authors": [
"Jaredlll08"
],
"environment": "client",
"description": "${DESCRIPTION}",
"authors": ["${AUTHOR}"],
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/ambient-environment",
"sources": "https://github.com/jaredlll08/Ambient-Environment",
"issues": "https://github.com/jaredlll08/Ambient-Environment/issues"
"homepage": "${CURSE_HOMEPAGE}",
"sources": "${GIT_REPO}",
"issues": "${GIT_REPO}/issues"
},
"license": "MIT",
"environment": "client",
"entrypoints": {
"client": [
"com.blamejared.ambientenvironment.AmbientEnvironment"
]
},
"depends": {
"fabricloader": ">=0.14",
"minecraft": "1.20.2"
"fabricloader": ">=${FABRIC_LOADER}",
"java": ">=${JAVA}",
"minecraft": "${MINECRAFT}"
},
"recommends": {
"fabric": "*"
},
"mixins": [
{
Expand Down
8 changes: 6 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ dependencies {
}

tasks.create<TaskPublishCurseForge>("publishCurseForge") {
dependsOn(tasks.jar)
apiToken = GMUtils.locateProperty(project, "curseforgeApiToken") ?: 0

val mainFile = upload(Properties.CURSE_PROJECT_ID, file("${project.buildDir}/libs/${base.archivesName.get()}-$version.jar"))
val mainFile = upload(Properties.CURSE_PROJECT_ID, file("${project.layout.buildDirectory}/libs/${base.archivesName.get()}-$version.jar"))
mainFile.changelogType = "markdown"
mainFile.changelog = GMUtils.smallChangelog(project, Properties.GIT_REPO)
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_RELEASE
mainFile.addJavaVersion("Java ${Versions.JAVA}")
mainFile.addGameVersion(Versions.MINECRAFT)

doLast {
project.ext.set("curse_file_url", "${Properties.CURSE_HOMEPAGE}/files/${mainFile.curseFileId}")
Expand All @@ -61,5 +63,7 @@ modrinth {
changelog.set(GMUtils.smallChangelog(project, Properties.GIT_REPO))
versionName.set("Forge-${Versions.MINECRAFT}-$version")
versionType.set("release")
gameVersions.set(listOf(Versions.MINECRAFT))
uploadFile.set(tasks.jar.get())
}
}
tasks.modrinth.get().dependsOn(tasks.jar)
38 changes: 24 additions & 14 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
modLoader="javafml"
loaderVersion="[31,)"
license="MIT"
issueTrackerURL="https://github.com/jaredlll08/Ambient-Environment/issues"
modLoader = "javafml"
loaderVersion = "${FORGE_LOADER}"
issueTrackerURL = "${GIT_REPO}/issues"
license = "MIT"
[[mods]]
modId="ambientenvironment"
version="${file.jarVersion}"
displayName="Ambient Environment"
credits="MC Bedrock edition lol"
authors="Jaredlll08"
updateJSONURL="https://updates.blamejared.com/get?n=AmbientEnvironment&gv=1.20.2"
description='''
Adds more ambiance to the game
'''
displayURL="https://www.curseforge.com/minecraft/mc-mods/ambient-environment"
modId = "${MODID}"
updateJSONURL = "https://updates.blamejared.com/get?n=${MODID}&gv=${MINECRAFT}&ml=forge"
version = "${version}"
displayName = "${NAME}"
displayURL = "${CURSE_HOMEPAGE}"
authors = "${AUTHOR}"
description = '''${DESCRIPTION}'''
itemIcon = "${ITEM_ICON}"
[[dependencies.${MODID}]]
modId = "forge"
mandatory = true
versionRange = "${FORGE_LOADER}"
ordering = "NONE"
side = "BOTH"
[[dependencies.${MODID}]]
modId = "minecraft"
mandatory = true
versionRange = "[${MINECRAFT}]"
ordering = "NONE"
side = "BOTH"
6 changes: 0 additions & 6 deletions forge/src/main/resources/pack.mcmeta

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 8934b00

Please sign in to comment.