Skip to content

Commit

Permalink
Port to NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Jul 21, 2024
1 parent 3330ed4 commit a8f993c
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 288 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/docs.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/release.yml

This file was deleted.

177 changes: 51 additions & 126 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,160 +1,85 @@
plugins {
id 'fabric-loom' version '1.6.+'
id 'eclipse'
id 'idea'
id 'java-library'
id 'net.neoforged.moddev' version '1.0.0'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
}

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
base {
archivesName = project.mod_id
}
version = project.mod_version
group = project.maven_group

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

maven { url "https://maven.nucleoid.xyz" }
maven { url "https://jitpack.io" }
}
neoForge {
version = project.neo_version

loom {
runs {
parchment {
minecraftVersion = minecraft_version
mappingsVersion = parchment_version
}
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
runs {
client {
client()
programArguments.addAll '--username', 'Dev###'
}

// Fabric API. This is technically optional, but you probably want it anyway.
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompileOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
}
server {
server()
programArgument '--nogui'
}

processResources {
inputs.property "version", project.version
configureEach {
logLevel = org.slf4j.event.Level.WARN
}
}

filesMatching("fabric.mod.json") {
expand "version": project.version
mods {
"${project.mod_id}" {
sourceSet sourceSets.main
}
}
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
mod_id: mod_id,
mod_version: mod_version,
]
inputs.properties replaceProperties

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
it.options.release = 21
filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}

def env = System.getenv()

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
register('mavenJava', MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
repositories {
if (env.MAVEN_URL) {
maven {
credentials {
username env.MAVEN_USERNAME
password env.MAVEN_PASSWORD
}
url env.MAVEN_URL
}
} else {
mavenLocal()
}
}
}
}

if (System.getenv("MODRINTH")) {
modrinth {
token = System.getenv("MODRINTH")
projectId = 'eXts2L7r'// The ID of your modrinth project, slugs will not work.
versionNumber = "" + version // The version of the mod to upload.
versionType = "release"
uploadFile = remapJar // This links to a task that builds your mod jar and sets "uploadFile" to the mod jar.
gameVersions = [((String) project.minecraft_version)]
changelog = System.getenv("CHANGELOG")
loaders = ["fabric", "quilt"]
}

remapJar {
finalizedBy project.tasks.modrinth
}
}


curseforge {
if (System.getenv("CURSEFORGE")) {
apiKey = System.getenv("CURSEFORGE")

project {
id = "1037459"
releaseType = "release"
changelog = System.getenv("CHANGELOG")
changelogType = "markdown"
addGameVersion((project.minecraft_version.contains("-") ? ((String) project.minecraft_version.split("-")[0] + "-Snapshot") : project.minecraft_version))
addGameVersion "Fabric"
addGameVersion "Quilt"
mainArtifact(remapJar)

afterEvaluate {
uploadTask.dependsOn("remapJar")
}
if (project.hasProperty('mavendir')) {
maven { url mavendir }
} else {
mavenLocal()
}
}

options {
forgeGradleIntegration = false
}
remapJar {
finalizedBy project.tasks.curseforge
}
}
27 changes: 11 additions & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

#Fabric api
fabric_version=0.100.1+1.21

# Mod Properties
mod_version = 2.4.1+1.21
maven_group = eu.pb4
archives_base_name = placeholder-api
mod_id=placeholder-api
maven_group=eu.pb4
mod_version=2.4.1+1.21
minecraft_version=1.21
neo_version=21.0.58-beta
parchment_version=2024.06.23

org.gradle.jvmargs=-Xmx1G
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a8f993c

Please sign in to comment.