update gradle to neoforge

This commit is contained in:
Ell 2024-02-03 14:49:36 +01:00
parent 4f3beab0f4
commit 46451bc093
3 changed files with 86 additions and 193 deletions

View file

@ -1,17 +1,25 @@
plugins { plugins {
id 'java-library'
id 'eclipse' id 'eclipse'
id 'idea' id 'idea'
id 'maven-publish' id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'net.neoforged.gradle.userdev' version '7.0.80'
} }
version = mod_version version = mod_version
if (System.getenv('CI_PIPELINE_NUMBER') != null) {
version += "." + System.getenv('CI_PIPELINE_NUMBER')
}
group = mod_group_id group = mod_group_id
repositories {
mavenLocal()
maven {
url = "https://maven.blamejared.com"
}
maven {
url = "https://maven.theillusivec4.top/"
}
}
base { base {
archivesName = mod_name archivesName = mod_name
} }
@ -20,147 +28,72 @@ base {
java.toolchain.languageVersion = JavaLanguageVersion.of(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'}" println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft { runs {
// The mappings can be changed at any time and must be in the following format. // applies to all the run configs below
// Channel: Version: configureEach {
// official MCVersion Official field/method names from Mojang mapping files // Recommended logging data for a userdev environment
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official // The markers can be added/remove as needed separated by commas.
// // "SCAN": For mods scan.
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. // "REGISTRIES": For firing of registry events.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md // "REGISTRYDUMP": For getting the contents of all registries.
// systemProperty 'forge.logging.markers', 'REGISTRIES'
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mapping_channel, version: mapping_version
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // Recommended logging level for the console
// In most cases, it is not necessary to enable. // You can set various levels here.
// enableEclipsePrepareRuns = true // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
// enableIdeaPrepareRuns = true systemProperty 'forge.logging.console.level', 'info'
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. modSource project.sourceSets.main
// 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
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. client {
// The folder name can be set on a run configuration using the "folderName" property. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
// By default, the folder name of a run configuration is the name of the Gradle project containing it. systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
// generateRunFolders = true }
// This property enables access transformers for use in development. server {
// They will be applied to the Minecraft artifact. systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
// The access transformer file can be anywhere in the project. programArgument '--nogui'
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge. }
// This default location is a best practice to automatically put the file in the right place in the final jar.
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations. // This run config launches GameTestServer and runs all registered gametests, then exits.
// These can be tweaked, removed, or duplicated as needed. // By default, the server will crash when no gametests are provided.
runs { // The gametest system is also enabled by default for other run configs under the /test command.
// applies to all the run configs below gameTestServer {
configureEach { systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
workingDirectory project.file('run') }
// Recommended logging data for a userdev environment data {
// The markers can be added/remove as needed separated by commas. // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// "SCAN": For mods scan. // workingDirectory project.file('run-data')
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
// You can set various levels here. programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'info'
mods {
"${mod_id}" {
source sourceSets.main
}
}
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', mod_id
}
server {
property 'forge.enabledGameTestNamespaces', mod_id
args '--nogui'
}
// 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 {
property 'forge.enabledGameTestNamespaces', mod_id
}
data {
// example of overriding the workingDirectory set in configureEach above
workingDirectory project.file('run-data')
// 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/')
}
} }
} }
// Include resources generated by data generators. // Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' } sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
// flatDir {
// dir 'libs'
// }
// it says this gets included automatically but apparently it doesn't
mavenCentral()
maven {
url = "https://maven.blamejared.com"
}
maven {
url = "https://maven.theillusivec4.top/"
}
maven {
url = "https://maven.ellpeck.de"
}
}
dependencies { dependencies {
// Specify the version of Minecraft to use. // Specify the version of Minecraft to use.
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact. // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
// The "userdev" classifier will be requested and setup by ForgeGradle. // The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"], // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation "net.neoforged:neoforge:${neo_version}"
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") compileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}") compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}") runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}") runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api") compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}:api") compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}") runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
// Example mod dependency using a mod jar from ./libs with a flat dir repository // Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
@ -176,38 +109,21 @@ dependencies {
// A missing property will result in an error. Properties are expanded using ${} Groovy notation. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure { tasks.withType(ProcessResources).configureEach {
var replaceProperties = [ var replaceProperties = [
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version : forge_version, forge_version_range: forge_version_range, neo_version : neo_version, neo_version_range: neo_version_range,
loader_version_range: loader_version_range, loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: version, mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description, mod_authors : mod_authors, mod_description: mod_description,
] ]
inputs.properties replaceProperties inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { filesMatching(['META-INF/mods.toml']) {
expand replaceProperties + [project: project] expand replaceProperties + [project: project]
} }
} }
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
// This is the preferred method to reobfuscate your jar file
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: // 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:
// tasks.named('publish').configure { // tasks.named('publish').configure {
// dependsOn 'reobfJar' // dependsOn 'reobfJar'
@ -217,19 +133,12 @@ tasks.named('jar', Jar).configure {
publishing { publishing {
publications { publications {
register('mavenJava', MavenPublication) { register('mavenJava', MavenPublication) {
groupId mod_group_id from components.java
artifactId mod_name
artifact jar
pom.withXml {
def node = asNode()
if (node.dependencies.size() > 0)
node.remove(node.dependencies)
}
} }
} }
repositories { repositories {
maven { maven {
url "file://" + System.getenv("LOCAL_MAVEN") url "file://${project.projectDir}/repo"
} }
} }
} }

View file

@ -1,41 +1,27 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. org.gradle.debug=false
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G #read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
org.gradle.daemon=false # you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
## Environment Properties neogradle.subsystems.parchment.minecraftVersion=1.20.3
# The Minecraft version must agree with the Forge version to get a valid artifact neogradle.subsystems.parchment.mappingsVersion=2023.12.31
minecraft_version=1.20.1 # Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.20.4
# The Minecraft version range can use any release version of Minecraft as bounds. # The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions. # as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21) minecraft_version_range=[1.20.4,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact # The Neo version must agree with the Minecraft version to get a valid artifact
forge_version=47.1.0 neo_version=20.4.80-beta
# The Forge version range can use any version of Forge as bounds or match the loader version range # The Neo version range can use any version of Neo as bounds
forge_version_range=[47,) neo_version_range=[20.4,)
# The loader version range can only use the major version of Forge/FML as bounds # The loader version range can only use the major version of FML as bounds
loader_version_range=[47,) loader_version_range=[2,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. jei_version=17.3.0.48
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. curios_version=7.2.0+1.20.4
# patchouli_version=1.20.4-85-NEOFORGE-SNAPSHOT
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.1
jei_version=15.2.0.22
curios_version=5.2.0-beta.3+1.20.1
patchouli_version=1.20.1-80-FORGE-SNAPSHOT
## Mod Properties ## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} # The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}

View file

@ -1,10 +1,8 @@
pluginManagement { pluginManagement {
repositories { repositories {
mavenLocal()
gradlePluginPortal() gradlePluginPortal()
maven { maven { url = 'https://maven.neoforged.net/releases' }
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
} }
} }