Skip to content

Commit 46451bc

Browse files
committed
update gradle to neoforge
1 parent 4f3beab commit 46451bc

File tree

3 files changed

+88
-195
lines changed

3 files changed

+88
-195
lines changed

build.gradle

+64-155
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
plugins {
2+
id 'java-library'
23
id 'eclipse'
34
id 'idea'
45
id 'maven-publish'
5-
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
6+
id 'net.neoforged.gradle.userdev' version '7.0.80'
67
}
78

89
version = mod_version
9-
if (System.getenv('CI_PIPELINE_NUMBER') != null) {
10-
version += "." + System.getenv('CI_PIPELINE_NUMBER')
11-
}
12-
1310
group = mod_group_id
1411

12+
repositories {
13+
mavenLocal()
14+
15+
maven {
16+
url = "https://maven.blamejared.com"
17+
}
18+
maven {
19+
url = "https://maven.theillusivec4.top/"
20+
}
21+
}
22+
1523
base {
1624
archivesName = mod_name
1725
}
@@ -20,147 +28,72 @@ base {
2028
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
2129

2230
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
23-
minecraft {
24-
// The mappings can be changed at any time and must be in the following format.
25-
// Channel: Version:
26-
// official MCVersion Official field/method names from Mojang mapping files
27-
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
28-
//
29-
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
30-
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
31-
//
32-
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
33-
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
34-
//
35-
// Use non-default mappings at your own risk. They may not always work.
36-
// Simply re-run your setup task after changing the mappings to update your workspace.
37-
mappings channel: mapping_channel, version: mapping_version
38-
39-
// 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.
40-
// In most cases, it is not necessary to enable.
41-
// enableEclipsePrepareRuns = true
42-
// enableIdeaPrepareRuns = true
43-
44-
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
45-
// It is REQUIRED to be set to true for this template to function.
46-
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
47-
copyIdeResources = true
48-
49-
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
50-
// The folder name can be set on a run configuration using the "folderName" property.
51-
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
52-
// generateRunFolders = true
53-
54-
// This property enables access transformers for use in development.
55-
// They will be applied to the Minecraft artifact.
56-
// The access transformer file can be anywhere in the project.
57-
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
58-
// This default location is a best practice to automatically put the file in the right place in the final jar.
59-
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
60-
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
61-
62-
// Default run configurations.
63-
// These can be tweaked, removed, or duplicated as needed.
64-
runs {
65-
// applies to all the run configs below
66-
configureEach {
67-
workingDirectory project.file('run')
68-
69-
// Recommended logging data for a userdev environment
70-
// The markers can be added/remove as needed separated by commas.
71-
// "SCAN": For mods scan.
72-
// "REGISTRIES": For firing of registry events.
73-
// "REGISTRYDUMP": For getting the contents of all registries.
74-
property 'forge.logging.markers', 'REGISTRIES'
75-
76-
// Recommended logging level for the console
77-
// You can set various levels here.
78-
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
79-
property 'forge.logging.console.level', 'info'
80-
81-
mods {
82-
"${mod_id}" {
83-
source sourceSets.main
84-
}
85-
}
86-
87-
property 'mixin.env.remapRefMap', 'true'
88-
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
89-
}
31+
runs {
32+
// applies to all the run configs below
33+
configureEach {
34+
// Recommended logging data for a userdev environment
35+
// The markers can be added/remove as needed separated by commas.
36+
// "SCAN": For mods scan.
37+
// "REGISTRIES": For firing of registry events.
38+
// "REGISTRYDUMP": For getting the contents of all registries.
39+
systemProperty 'forge.logging.markers', 'REGISTRIES'
40+
41+
// Recommended logging level for the console
42+
// You can set various levels here.
43+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
44+
systemProperty 'forge.logging.console.level', 'info'
45+
46+
modSource project.sourceSets.main
47+
}
9048

91-
client {
92-
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
93-
property 'forge.enabledGameTestNamespaces', mod_id
94-
}
49+
client {
50+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
51+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
52+
}
9553

96-
server {
97-
property 'forge.enabledGameTestNamespaces', mod_id
98-
args '--nogui'
99-
}
54+
server {
55+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
56+
programArgument '--nogui'
57+
}
10058

101-
// This run config launches GameTestServer and runs all registered gametests, then exits.
102-
// By default, the server will crash when no gametests are provided.
103-
// The gametest system is also enabled by default for other run configs under the /test command.
104-
gameTestServer {
105-
property 'forge.enabledGameTestNamespaces', mod_id
106-
}
59+
// This run config launches GameTestServer and runs all registered gametests, then exits.
60+
// By default, the server will crash when no gametests are provided.
61+
// The gametest system is also enabled by default for other run configs under the /test command.
62+
gameTestServer {
63+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
64+
}
10765

108-
data {
109-
// example of overriding the workingDirectory set in configureEach above
110-
workingDirectory project.file('run-data')
66+
data {
67+
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
68+
// workingDirectory project.file('run-data')
11169

112-
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
113-
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
114-
}
70+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
71+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
11572
}
11673
}
11774

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

121-
repositories {
122-
// Put repositories for dependencies here
123-
// ForgeGradle automatically adds the Forge maven and Maven Central for you
124-
125-
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
126-
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
127-
// flatDir {
128-
// dir 'libs'
129-
// }
130-
131-
// it says this gets included automatically but apparently it doesn't
132-
mavenCentral()
133-
134-
maven {
135-
url = "https://maven.blamejared.com"
136-
}
137-
maven {
138-
url = "https://maven.theillusivec4.top/"
139-
}
140-
maven {
141-
url = "https://maven.ellpeck.de"
142-
}
143-
}
144-
14578
dependencies {
14679
// Specify the version of Minecraft to use.
14780
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
14881
// The "userdev" classifier will be requested and setup by ForgeGradle.
14982
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
15083
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
151-
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
84+
implementation "net.neoforged:neoforge:${neo_version}"
15285

15386
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
15487
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
155-
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
156-
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
157-
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
88+
compileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"
89+
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
90+
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
15891

159-
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
160-
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
92+
runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
93+
compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
16194

162-
compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}:api")
163-
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
95+
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
96+
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
16497

16598
// Example mod dependency using a mod jar from ./libs with a flat dir repository
16699
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
@@ -176,38 +109,21 @@ dependencies {
176109
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
177110
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
178111
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
179-
tasks.named('processResources', ProcessResources).configure {
112+
tasks.withType(ProcessResources).configureEach {
180113
var replaceProperties = [
181114
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
182-
forge_version : forge_version, forge_version_range: forge_version_range,
115+
neo_version : neo_version, neo_version_range: neo_version_range,
183116
loader_version_range: loader_version_range,
184-
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: version,
117+
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
185118
mod_authors : mod_authors, mod_description: mod_description,
186119
]
187120
inputs.properties replaceProperties
188121

189-
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
122+
filesMatching(['META-INF/mods.toml']) {
190123
expand replaceProperties + [project: project]
191124
}
192125
}
193126

194-
// Example for how to get properties into the manifest for reading at runtime.
195-
tasks.named('jar', Jar).configure {
196-
manifest {
197-
attributes([
198-
'Specification-Title' : mod_id,
199-
'Specification-Vendor' : mod_authors,
200-
'Specification-Version' : '1', // We are version 1 of ourselves
201-
'Implementation-Title' : project.name,
202-
'Implementation-Version' : project.jar.archiveVersion,
203-
'Implementation-Vendor' : mod_authors,
204-
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
205-
])
206-
}
207-
// This is the preferred method to reobfuscate your jar file
208-
finalizedBy 'reobfJar'
209-
}
210-
211127
// 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:
212128
// tasks.named('publish').configure {
213129
// dependsOn 'reobfJar'
@@ -217,23 +133,16 @@ tasks.named('jar', Jar).configure {
217133
publishing {
218134
publications {
219135
register('mavenJava', MavenPublication) {
220-
groupId mod_group_id
221-
artifactId mod_name
222-
artifact jar
223-
pom.withXml {
224-
def node = asNode()
225-
if (node.dependencies.size() > 0)
226-
node.remove(node.dependencies)
227-
}
136+
from components.java
228137
}
229138
}
230139
repositories {
231140
maven {
232-
url "file://" + System.getenv("LOCAL_MAVEN")
141+
url "file://${project.projectDir}/repo"
233142
}
234143
}
235144
}
236145

237146
tasks.withType(JavaCompile).configureEach {
238147
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
239-
}
148+
}

gradle.properties

+21-35
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
1-
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
2-
# This is required to provide enough memory for the Minecraft decompilation process.
3-
org.gradle.jvmargs=-Xmx3G
4-
org.gradle.daemon=false
5-
## Environment Properties
6-
# The Minecraft version must agree with the Forge version to get a valid artifact
7-
minecraft_version=1.20.1
1+
org.gradle.debug=false
2+
3+
#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
4+
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
5+
neogradle.subsystems.parchment.minecraftVersion=1.20.3
6+
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
7+
# Environment Properties
8+
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
9+
# The Minecraft version must agree with the Neo version to get a valid artifact
10+
minecraft_version=1.20.4
811
# The Minecraft version range can use any release version of Minecraft as bounds.
912
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
1013
# as they do not follow standard versioning conventions.
11-
minecraft_version_range=[1.20.1,1.21)
12-
# The Forge version must agree with the Minecraft version to get a valid artifact
13-
forge_version=47.1.0
14-
# The Forge version range can use any version of Forge as bounds or match the loader version range
15-
forge_version_range=[47,)
16-
# The loader version range can only use the major version of Forge/FML as bounds
17-
loader_version_range=[47,)
18-
# The mapping channel to use for mappings.
19-
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
20-
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
21-
#
22-
# | Channel | Version | |
23-
# |-----------|----------------------|--------------------------------------------------------------------------------|
24-
# | official | MCVersion | Official field/method names from Mojang mapping files |
25-
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
26-
#
27-
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
28-
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
29-
#
30-
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
31-
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
32-
mapping_channel=official
33-
# The mapping version to query from the mapping channel.
34-
# This must match the format required by the mapping channel.
35-
mapping_version=1.20.1
36-
jei_version=15.2.0.22
37-
curios_version=5.2.0-beta.3+1.20.1
38-
patchouli_version=1.20.1-80-FORGE-SNAPSHOT
14+
minecraft_version_range=[1.20.4,1.21)
15+
# The Neo version must agree with the Minecraft version to get a valid artifact
16+
neo_version=20.4.80-beta
17+
# The Neo version range can use any version of Neo as bounds
18+
neo_version_range=[20.4,)
19+
# The loader version range can only use the major version of FML as bounds
20+
loader_version_range=[2,)
21+
22+
jei_version=17.3.0.48
23+
curios_version=7.2.0+1.20.4
24+
patchouli_version=1.20.4-85-NEOFORGE-SNAPSHOT
3925

4026
## Mod Properties
4127
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}

settings.gradle

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
pluginManagement {
22
repositories {
3+
mavenLocal()
34
gradlePluginPortal()
4-
maven {
5-
name = 'MinecraftForge'
6-
url = 'https://maven.minecraftforge.net/'
7-
}
5+
maven { url = 'https://maven.neoforged.net/releases' }
86
}
97
}
108

119
plugins {
1210
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
13-
}
11+
}

0 commit comments

Comments
 (0)