Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 53 additions & 114 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,113 +1,54 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}

plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0.14,6.2)'
id 'net.neoforged.gradle.userdev' version '7.0.171'
}

version = "${mcversion}-${version_major}.${version_minor}"
group = "${author}.${modid}"
archivesBaseName = "${modid}"

// 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: project.mcp_channel, version: project.mcp_mappings

// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true

runs {
client {
workingDirectory project.file("run/client").canonicalPath

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

// 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', modid

mods {
constructionwand {
source sourceSets.main
}
}
}

server {
workingDirectory project.file("run/server").canonicalPath

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

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

// property 'forge.enabledGameTestNamespaces', modid

mods {
constructionwand {
source sourceSets.main
}
}
}
base {
archivesName = "${modid}"
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

property 'forge.logging.markers', 'REGISTRIES'
//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager

property 'forge.logging.console.level', 'debug'
runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
systemProperty 'forge.logging.markers', 'REGISTRIES'

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

mods {
examplemod {
source sourceSets.main
}
}
}
//Limit ram usage for the dev environment to 4GB
jvmArgument '-Xmx4G'

data {
workingDirectory project.file("run/client").canonicalPath
modSource project.sourceSets.main
}

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

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

args '--mod', archivesBaseName, '--all',
'--existing', '"' + file('src/main/resources/') + '"',
'--existing', '"' + file('src/generated/resources/') + '"',
'--output', '"' + file('src/generated/resources/') + '"'
data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')

mods {
constructionwand {
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', "${modid}", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

Expand All @@ -125,22 +66,18 @@ repositories {
}

dependencies {
minecraft([
group : "net.minecraftforge",
name : "forge",
version: "${project.mcversion}-${project.forgeversion}"
])

compileOnly fg.deobf("mezz.jei:jei-${mcversion}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${mcversion}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${mcversion}-forge:${jei_version}")

compileOnly fg.deobf([
group: "vazkii.botania",
name: "Botania",
version: "${project.botania}",
classifier: "api"
])
implementation "net.neoforged:neoforge:${neoversion}"

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

// compileOnly ([
// group: "vazkii.botania",
// name: "Botania",
// version: "${project.botania}",
// classifier: "api"
// ])
}

jar {
Expand All @@ -157,12 +94,6 @@ jar {
}
}

// Example configuration to allow publishing using the maven-publish task
// 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')

publishing {
publications {
mavenJava(MavenPublication) {
Expand All @@ -176,6 +107,14 @@ publishing {
}
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}

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

mcversion=1.20.2
forgeversion=48.0.30
mcp_channel=official
mcp_mappings=1.20.2
mcversion=1.21.1
neoversion=21.1.84
neogradle.subsystems.parchment.minecraftVersion=1.21.1
neogradle.subsystems.parchment.mappingsVersion=2024.11.17
neogradle.subsystems.conventions.runs.create-default-run-per-type=false

# Source: https://maven.blamejared.com/vazkii/botania/Botania/
botania=1.20.1-441-FORGE-SNAPSHOT
# Source: https://maven.blamejared.com/mezz/jei/
jei_version=16.0.0.28
jei_version=19.21.0.247

version_major=2
version_minor=12
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.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
44 changes: 31 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +82,12 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +134,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=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=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +201,28 @@ 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" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading