Skip to content

Commit

Permalink
Initial port to 1.20.4 NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Feb 17, 2024
1 parent a12d489 commit 3fcb522
Show file tree
Hide file tree
Showing 36 changed files with 199 additions and 256 deletions.
176 changes: 78 additions & 98 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'net.neoforged.gradle.userdev' version '7.0.93'
id 'net.darkhax.curseforgegradle' version '1.1.17'
id 'com.modrinth.minotaur' version "2.+"
}

Expand All @@ -16,104 +17,63 @@ base {
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
mappings channel: mapping_channel, version: mapping_version
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager

copyIdeResources = true
runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
systemProperty 'forge.logging.markers', 'REGISTRIES'

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Recommended logging level for the console
systemProperty 'forge.logging.console.level', 'debug'

runs {
client {
workingDirectory project.file('run')
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"

// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.markers', 'REGISTRIES'
//Limit ram usage for the dev environment to 4GB
jvmArgument '-Xmx4G'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', "${mod_id}"

mods {
"${mod_id}" {
source sourceSets.main
}
}
}

server {
workingDirectory project.file('run')
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"

// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', "${mod_id}"

mods {
"${mod_id}" {
source sourceSets.main
}
}
}

data {
workingDirectory project.file('run')
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
modSource project.sourceSets.main
}

// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.markers', 'REGISTRIES'
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', "${mod_id}"
}

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
server {
systemProperty 'neoforge.enabledGameTestNamespaces', "${mod_id}"
programArgument '--nogui'
}

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', "${mod_id}", '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')

mods {
"${mod_id}" {
source sourceSets.main
}
}
}
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', "${mod_id}", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
maven {
maven {
url = "https://maven.blamejared.com"
}
}
}

dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
implementation "net.neoforged:neoforge:${neo_version}"

compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"

runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
runtimeOnly "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"

implementation fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-${mc_version}:${crafttweaker_version}")
implementation "com.blamejared.crafttweaker:CraftTweaker-neoforge-${mc_version}:${crafttweaker_version}"
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
Expand All @@ -128,25 +88,13 @@ jar {
}
}

// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')

def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(reobfArtifact) {
builtBy reobfArtifact
artifactId = base.archivesName.get()
classifier null
}
register('mavenJava', MavenPublication) {
groupId project.group
artifactId base.archivesName.get()
version project.version
from components.java
}
}
repositories {
Expand All @@ -162,9 +110,41 @@ publishing {
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
if (System.getenv().CURSEFORGE_KEY) {
task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
apiToken = System.getenv().CURSEFORGE_KEY

def mainFile = upload(project.curseforge_id, jar)
mainFile.releaseType = 'beta'
mainFile.addGameVersion "NeoForge"
mainFile.addGameVersion "${mc_version}"
mainFile.addGameVersion "Java 17"

mainFile.changelog = file("$project.rootDir/changelog.md")
mainFile.changelogType = 'markdown'

mainFile.addOptional("crafttweaker")
}
}

apply from: 'gradle/curseforge.gradle'
apply from: 'gradle/modrinth.gradle'
if (System.getenv().MODRINTH_KEY) {
modrinth {
token = System.getenv().MODRINTH_KEY
projectId = project.modrinth_id
versionType = "beta"
versionName = "${mod_name} ${mc_version}"
versionNumber = project.version
uploadFile = jar
changelog = file("$project.rootDir/changelog.md").text
gameVersions = ["${mc_version}"]
loaders = ["neoforge"]

dependencies {
optional.project "crafttweaker"
}
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

# Base info
mc_version=1.20.1
forge_version=47.1.3
mapping_channel=official
mapping_version=1.20.1
mc_version=1.20.4
neo_version=20.4.161-beta
neogradle.subsystems.parchment.minecraftVersion=1.20.3
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
mod_group=com.mrbysco.angrymobs
mod_id=angrymobs
mod_archive_name=AngryMobs
Expand All @@ -18,8 +18,8 @@ curseforge_id=430225
modrinth_id=W9PF5nLR

# Version
version=4.1.0
version=5.0.0

# Mod support
jei_version=15.2.0.23
crafttweaker_version=14.0.17
# Dependencies
jei_version=17.3.0.49
crafttweaker_version=17.0.7
22 changes: 0 additions & 22 deletions gradle/curseforge.gradle

This file was deleted.

20 changes: 0 additions & 20 deletions gradle/modrinth.gradle

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.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Loading

0 comments on commit 3fcb522

Please sign in to comment.