Skip to content

Commit

Permalink
Add NeoForge project (#464)
Browse files Browse the repository at this point in the history
* Port to NeoForge

* Symlink fixes
  • Loading branch information
embeddedt authored Apr 17, 2024
1 parent 6290333 commit a6785ac
Show file tree
Hide file tree
Showing 17 changed files with 544 additions and 15 deletions.
25 changes: 14 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ group = project.maven_group
apply from: 'common.gradle'

def createLink(source, target) {
if (new File(target).exists()) {
if (new File(rootProject.projectDir, target).exists()) {
println("Target ${target} already exists, skipping symbolic link creation")
return
}

try {
exec {
source = new File(projectDir, source).getCanonicalPath()
target = new File(projectDir, target).getCanonicalPath()
source = new File(rootProject.projectDir, source).getCanonicalPath()
target = new File(rootProject.projectDir, target).getCanonicalPath()
new File(target).getParentFile().mkdirs()

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
Expand All @@ -43,13 +43,18 @@ def createLink(source, target) {

def setupLinks() {
println("Setting up symbolic links...")
createLink("./src/main/java/com/aizistral/nochatreports/common", "./forge/src/main/java/com/aizistral/nochatreports/common")
createLink("./src/main/resources/assets", "./forge/src/main/resources/assets")
createLink("./src/main/resources/mixins/common", "./forge/src/main/resources/mixins/common")

if (!new File("./forge/src/main/java/com/aizistral/nochatreports/common/platform/PlatformProvider.java").exists()) {
throw new IllegalStateException("No PlatformProvider found :/")

for(platform in ["forge", "neoforge"]) {
createLink("./src/main/java/com/aizistral/nochatreports/common", "./${platform}/src/main/java/com/aizistral/nochatreports/common")
createLink("./src/main/resources/assets", "./${platform}/src/main/resources/assets")
createLink("./src/main/resources/mixins/common", "./${platform}/src/main/resources/mixins/common")

if (!new File("./${platform}/src/main/java/com/aizistral/nochatreports/common/platform/PlatformProvider.java").exists()) {
throw new IllegalStateException("No PlatformProvider found :/")
}
}

createLink("./forge/deps", "./neoforge/deps")
}

setupLinks()
Expand Down Expand Up @@ -80,8 +85,6 @@ dependencies {
}
}

sourceSets.remove(sourceSets.test)

processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
inputs.property "version", project.version
Expand Down
5 changes: 2 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
}
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.18'
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
classpath 'org.spongepowered:mixingradle:0.7.+'
}
Expand Down Expand Up @@ -103,7 +103,6 @@ minecraft {
}
}

sourceSets.remove(sourceSets.test)
sourceSets.main.resources {
// NO-OP
}
Expand Down Expand Up @@ -165,7 +164,7 @@ processResources {
'mod_icon': mod_icon,
'mod_description': mod_description,
'issue_tracker_url': issue_tracker_url,
'dep_forge': dep_forge,
'dep_forge': dep_forge,
'dep_minecraft': dep_minecraft,
'contributor_0': contributor_0
into 'META-INF'
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
fabric_loader_version=0.15.0
forge_version=1.20.4-49.0.3
neoforge_version=20.4.170

# Mod Properties
mod_version=1.20.4-v2.5.0
Expand All @@ -28,6 +29,7 @@ cloth_config_version=12.0.111

# Dependencies in mods.toml
dep_forge=[37,)
dep_neoforge=[20.4.170,)
dep_minecraft=[1.20.3,)

# Publishing
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
41 changes: 41 additions & 0 deletions neoforge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run

# Aizistral
.apt_generated
logs
omniconfig_first
*works
Users
.factorypath
deps/Soulbound*
multiuser_args.txt
old_enigmatic_desc.txt
**/TestEventHandler*
/.apt_generated_tests/

# Symlink directories
deps
src/main/java/com/aizistral/nochatreports/common
src/main/resources/assets
src/main/resources/mixins/common
215 changes: 215 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
buildscript {
repositories {
mavenCentral()
maven { url "file:///${project.projectDir}/deps/" }
maven { url 'https://plugins.gradle.org/m2/' }
maven {
name "Gradle Plugin Portal"
url 'https://plugins.gradle.org/m2/'
content {
includeGroup "gradle.plugin.com.matthewprenger"
includeGroup "com.modrinth"
}
}
}
dependencies {
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
}
}

plugins {
id "com.modrinth.minotaur" version "2.+"
id "net.neoforged.gradle.userdev" version "7.0.94"
}

println("Applying plugins...")

apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'com.matthewprenger.cursegradle'

apply from: '../common.gradle'

println("Specifying project version/group/archivesBaseName...")
version = "${mod_version}"
group = "${maven_group}"
archivesBaseName = "${archives_base_name}"

println("Specifying Java compatibility...")
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println("Java Installation Data:")
println(" - Java Version: " + System.getProperty('java.version'))
println(" - JVM Version: " + System.getProperty('java.vm.version'))
println(" - Vendor: " + System.getProperty('java.vendor'))
println(" - OS Archetype: " + System.getProperty('os.arch'))

compileJava.options.encoding = "UTF-8"

println("Specifying Access Transformer configuration...")

minecraft.accessTransformers.file project.file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
systemProperty 'org.gradle.jvmargs', '-Xms4G -Xmx4G'
systemProperty 'fml.earlyprogresswindow', 'false'
systemProperty 'mixin.env.disableRefMap', 'true'
workingDirectory project.file('run')

systemProperty 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
systemProperty 'forge.logging.console.level', 'debug'

modSource project.sourceSets.main
}

server {
systemProperty 'mixin.env.disableRefMap', 'true'
workingDirectory project.file('run')

systemProperty 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
systemProperty 'forge.logging.console.level', 'debug'

modSource project.sourceSets.main
}
}

sourceSets.main.resources {
// NO-OP
}

repositories {
println("Specifying repositories...")
maven { url "file:///${project.projectDir}/deps/" } // local
maven { url = "https://maven.theillusivec4.top/" } // curios
maven { url = "https://maven.blamejared.com/" } // patchouli
maven { url = "https://repo.spongepowered.org/maven" } // mixin
maven { url "https://maven.shedaniel.me/" } // cloth config
}

dependencies {
println("Processing dependencies...")

// Minecraft & Forge
implementation "net.neoforged:neoforge:${neoforge_version}"
implementation "generic:modmenu:5.0.2"
implementation "generic:fabric-annotations:v1.0.0"
implementation "me.shedaniel.cloth:cloth-config-neoforge:" + rootProject.cloth_config_version
}


jar {
println("Processing manifest...")

manifest {
attributes([
"Specification-Title": "${mod_name}",
"Specification-Vendor": "${mod_author}",
"Specification-Version": "${version}",
"Implementation-Title": "${mod_name}",
"Implementation-Version": "${version}",
"Implementation-Vendor" :"${mod_author}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
}

processResources {
println("Processing resources...")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude 'META-INF/mods.toml'

from("${project.projectDir}/docs/META-INF") {
println("Inflating mods.toml...")

// Replace properties in mods.toml with ones derived from settings.gradle
include 'mods.toml'
expand 'mod_license': mod_license,
'mod_version': version,
'mod_id' : mod_id,
'mod_name': mod_name,
'mod_url': mod_url,
'mod_author': mod_author,
'mod_icon': mod_icon,
'mod_description': mod_description,
'issue_tracker_url': issue_tracker_url,
'dep_neoforge': dep_neoforge,
'dep_minecraft': dep_minecraft,
'contributor_0': contributor_0
into 'META-INF'
}

from("${rootProject.projectDir}/docs") {
include 'CHANGELOG.md'
}

from("${rootProject.projectDir}") {
include 'LICENSE'
}
}

curseforge {

project {
println("Pushing CurseGradle specifications for project ID: ${curse_id}")

// Specified as cmd argument
apiKey = findProperty('curseKey') ?: 'none'

id = "${curse_id}"
releaseType = "${version_type}"
changelogType = 'markdown'
changelog = rootProject.file('docs/CHANGELOG.md')

addGameVersion project.minecraft_version
addGameVersion "Java 17"
addGameVersion "NeoForge"

//addArtifact(sourcesJar)
//addArtifact(apiJar)
}
}

modrinth {
token = findProperty('modrinthKey') ?: 'none'
projectId = "no-chat-reports"
versionNumber = "NeoForge-" + project.version
versionName = "No Chat Reports NeoForge-" + project.version
versionType = "${version_type}"
changelog = rootProject.file("docs/CHANGELOG.md").text
uploadFile = jar
gameVersions = [ project.minecraft_version ]

syncBodyFrom = rootProject.file("docs/README.md").text
}

task upload {
dependsOn('modrinth')
dependsOn('curseforge')
}


task updateResources() {
// NO-OP
}

tasks.updateResources.dependsOn processResources

//tasks.withType(JavaCompile) {
// options.failOnError(true)
//}

publishing {

publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
34 changes: 34 additions & 0 deletions neoforge/docs/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
license="${mod_license}"
modLoader="javafml"
loaderVersion="[1,)"
issueTrackerURL="${issue_tracker_url}"

[[mixins]]
config="mixins/common/nochatreports.mixins.json"

[[mixins]]
config="mixins/neoforge/nochatreports-neoforge.mixins.json"

[[mods]]
modId="${mod_id}"
version="${mod_version}"
displayName="${mod_name}"
displayURL="${mod_url}"
logoFile="${mod_icon}"
credits="${contributor_0}"
authors="${mod_author}"
description='''
${mod_description}
'''
[[dependencies.${mod_id}]]
modId="neoforge"
type="required"
versionRange="${dep_neoforge}"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="minecraft"
type="required"
versionRange="${dep_minecraft}"
ordering="NONE"
side="BOTH"
1 change: 1 addition & 0 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
archives_base_name=NoChatReports-NEOFORGE
Loading

0 comments on commit a6785ac

Please sign in to comment.