Skip to content

Commit

Permalink
Add neoforge support
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Dec 24, 2023
1 parent b953f4c commit 9bb8fc0
Show file tree
Hide file tree
Showing 26 changed files with 351 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ build
eclipse
run
run_server
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 @@ -62,4 +64,4 @@ tasks.create("postDiscord") {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,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 @@ -11,4 +11,6 @@ object Properties {
const val MODRINTH_PROJECT_ID = "Wnxd13zP"
const val FIRST_COMMIT = "d484fbdd8ed5d541deae66e97db3ed427f1963d6"
const val GIT_REPO = "https://github.com/jaredlll08/Clumps"
const val DESCRIPTION = "Clumps xp orbs together."
const val ITEM_ICON = "minecraft:experience_bottle"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ object Versions {
const val MOD = "13.0.0"
const val JAVA = "17"
const val MINECRAFT = "1.20.2"
const val FORGE = "48.0.1"
const val FABRIC_LOADER = "0.14.22"
const val FABRIC = "0.89.2+1.20.2"
const val FORGE = "48.0.1"
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/clumps.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"injectors": {
"defaultRequire": 1
},
"refmap": "${refmap_target}refmap.json"
"refmap": "${MODID}.refmap.json"
}
File renamed without changes
8 changes: 4 additions & 4 deletions common/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "clumps resources",
"pack_format": 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,38 +5,39 @@ 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.clumps.default")
id("com.blamejared.clumps.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}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${Versions.FABRIC}")
implementation(project(":common"))
}

loom {
mixin {
defaultRefmapName.set("${Properties.MODID}.refmap.json")
}
runs {
named("client") {
client()
setConfigName("Fabric Client")
configName = "Fabric Client"
ideConfigGenerated(true)
runDir("run")
}
}
}

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, tasks.remapJar.get().archiveFile)
mainFile.changelogType = "markdown"
mainFile.changelog = GMUtils.smallChangelog(project, Properties.GIT_REPO)
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_RELEASE
Expand All @@ -60,3 +61,4 @@ modrinth {
required.project("fabric-api")
}
}
tasks.modrinth.get().dependsOn(tasks.remapJar)
30 changes: 13 additions & 17 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
{
"schemaVersion": 1,
"id": "clumps",
"id": "${MODID}",
"name": "${NAME}",
"version": "${version}",
"name": "Clumps",
"description": "Clumps xp orbs together.",
"icon": "assets/clumps/icon.png",
"authors": [
"Jaredlll08"
],
"environment": "*",
"icon": "icon.png",
"authors": ["${AUTHOR}"],
"license": "MIT",
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/clumps",
"sources": "https://github.com/jaredlll08/clumps",
"issues": "https://github.com/jaredlll08/Clumps/issues"
"homepage": "${CURSE_HOMEPAGE}",
"sources": "${GIT_REPO}",
"issues": "${GIT_REPO}/issues"
},
"license": "MIT",
"environment": "*",
"description": "${DESCRIPTION}",
"entrypoints": {
"main": [
"com.blamejared.clumps.Clumps"
]
},
"depends": {
"fabricloader": ">=0.14",
"minecraft": "1.20.2"
"fabricloader": ">=${FABRIC_LOADER}",
"java": ">=${JAVA}",
"minecraft": "${MINECRAFT}"
},
"custom": {},
"mixins": [
Expand Down
6 changes: 4 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ 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, tasks.jar.get().archiveFile)
mainFile.changelogType = "markdown"
mainFile.changelog = GMUtils.smallChangelog(project, Properties.GIT_REPO)
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_RELEASE
Expand All @@ -62,4 +63,5 @@ modrinth {
versionName.set("Forge-${Versions.MINECRAFT}-$version")
versionType.set("release")
uploadFile.set(tasks.jar.get())
}
}
tasks.modrinth.get().dependsOn(tasks.jar)
34 changes: 22 additions & 12 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
modLoader = "javafml"
loaderVersion = "[41,)"
issueTrackerURL = "https://github.com/jaredlll08/Clumps/issues"
loaderVersion = "${FORGE_LOADER}"
issueTrackerURL = "${GIT_REPO}/issues"
license = "MIT"
[[mods]]
modId = "clumps"
version = "${file.jarVersion}"
displayName = "Clumps"
displayURL = "https://www.curseforge.com/minecraft/mc-mods/clumps"
updateJSONURL = "https://updates.blamejared.com/get?n=clumps&gv=1.20.2"
credits = ""
authors = "Jaredlll08"
modId = "${MODID}"
updateJSONURL = "https://updates.blamejared.com/get?n=${MODID}&gv=${MINECRAFT}&ml=forge"
version = "${version}"
displayName = "${NAME}"
displayURL = "${CURSE_HOMEPAGE}"
authors = "${AUTHOR}"
logoFile = "icon.png"
description = '''
Clumps xp orbs together.
'''
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"
Binary file removed forge/src/main/resources/icon.png
Binary file not shown.
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
56 changes: 56 additions & 0 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import com.blamejared.gradle.mod.utils.GMUtils
import com.blamejared.clumps.gradle.Properties
import com.blamejared.clumps.gradle.Versions
import net.darkhax.curseforgegradle.Constants
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
id("com.blamejared.clumps.default")
id("com.blamejared.clumps.loader")
id("net.neoforged.gradle.userdev") version ("7.0.71")
id("com.modrinth.minotaur")
}

runs {
configureEach {
modSource(project.sourceSets.main.get())
}
register("client") {
}
register("server") {
programArgument("--nogui")
}
}

dependencies {
implementation("net.neoforged:neoforge:${Versions.NEO_FORGE}")
compileOnly(project(":common"))
}

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

val mainFile = upload(Properties.CURSE_PROJECT_ID, tasks.jar.get().archiveFile)
mainFile.changelogType = "markdown"
mainFile.changelog = GMUtils.smallChangelog(project, Properties.GIT_REPO)
mainFile.releaseType = Constants.RELEASE_TYPE_RELEASE
mainFile.addJavaVersion("Java ${Versions.JAVA}")
mainFile.addGameVersion(Versions.MINECRAFT)
mainFile.addModLoader("NeoForge")

doLast {
project.ext.set("curse_file_url", "${Properties.CURSE_HOMEPAGE}/files/${mainFile.curseFileId}")
}
}

modrinth {
token.set(GMUtils.locateProperty(project, "modrinth_token"))
projectId.set(Properties.MODRINTH_PROJECT_ID)
changelog.set(GMUtils.smallChangelog(project, Properties.GIT_REPO))
versionName.set("NeoForge-${Versions.MINECRAFT}-$version")
versionType.set("release")
gameVersions.set(listOf(Versions.MINECRAFT))
uploadFile.set(tasks.jar.get())
}
tasks.modrinth.get().dependsOn(tasks.jar)

0 comments on commit 9bb8fc0

Please sign in to comment.