Skip to content

Commit f16fa2a

Browse files
committed
Port to NeoForge 1.20.2
1 parent 523f6d7 commit f16fa2a

23 files changed

+218
-307
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ build
2020
# other
2121
eclipse
2222
run
23+
runs
24+
run-data
2325

24-
# Files from Forge MDK
25-
forge*changelog.txt
26+
repo

build.gradle

Lines changed: 80 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,104 @@
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 'org.parchmentmc.librarian.forgegradle' version '1.+'
6+
id 'net.neoforged.gradle.userdev' version '7.0.5'
7+
// id 'org.parchmentmc.librarian.forgegradle' version '1.+'
78
}
89

910
version = mod_version
1011
group = mod_group_id
1112

13+
repositories {
14+
mavenLocal()
15+
}
16+
1217
base {
1318
archivesName = mod_id
1419
}
1520

1621
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
1722
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
1823

19-
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
20-
minecraft {
21-
// The mappings can be changed at any time and must be in the following format.
22-
// Channel: Version:
23-
// official MCVersion Official field/method names from Mojang mapping files
24-
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
25-
//
26-
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
27-
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
28-
//
29-
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
30-
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
31-
//
32-
// Use non-default mappings at your own risk. They may not always work.
33-
// Simply re-run your setup task after changing the mappings to update your workspace.
34-
mappings channel: mapping_channel, version: mapping_version
35-
36-
// When true, this property will have all Eclipse run configurations run the "prepareX" task for the given run configuration before launching the game.
37-
// In most cases, it is not necessary to enable.
38-
// enableEclipsePrepareRuns = true
39-
40-
// When true, this property will have all IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
41-
// In most cases, it is not necessary to enable.
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-
client {
66-
workingDirectory project.file('run')
67-
68-
// Recommended logging data for a userdev environment
69-
// The markers can be added/remove as needed separated by commas.
70-
// "SCAN": For mods scan.
71-
// "REGISTRIES": For firing of registry events.
72-
// "REGISTRYDUMP": For getting the contents of all registries.
73-
property 'forge.logging.markers', 'REGISTRIES'
74-
75-
// Recommended logging level for the console
76-
// You can set various levels here.
77-
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
78-
property 'forge.logging.console.level', 'debug'
79-
80-
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
81-
property 'forge.enabledGameTestNamespaces', mod_id
82-
83-
mods {
84-
"${mod_id}" {
85-
source sourceSets.main
86-
}
87-
}
88-
}
89-
90-
server {
91-
workingDirectory project.file('run')
92-
93-
property 'forge.logging.markers', 'REGISTRIES'
94-
95-
property 'forge.logging.console.level', 'debug'
96-
97-
property 'forge.enabledGameTestNamespaces', mod_id
98-
99-
mods {
100-
"${mod_id}" {
101-
source sourceSets.main
102-
}
103-
}
104-
}
105-
106-
// This run config launches GameTestServer and runs all registered gametests, then exits.
107-
// By default, the server will crash when no gametests are provided.
108-
// The gametest system is also enabled by default for other run configs under the /test command.
109-
gameTestServer {
110-
workingDirectory project.file('run')
111-
112-
property 'forge.logging.markers', 'REGISTRIES'
113-
114-
property 'forge.logging.console.level', 'debug'
115-
116-
property 'forge.enabledGameTestNamespaces', mod_id
117-
118-
mods {
119-
"${mod_id}" {
120-
source sourceSets.main
121-
}
122-
}
123-
}
24+
//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
25+
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
26+
27+
// Default run configurations.
28+
// These can be tweaked, removed, or duplicated as needed.
29+
runs {
30+
// applies to all the run configs below
31+
configureEach {
32+
// Recommended logging data for a userdev environment
33+
// The markers can be added/remove as needed separated by commas.
34+
// "SCAN": For mods scan.
35+
// "REGISTRIES": For firing of registry events.
36+
// "REGISTRYDUMP": For getting the contents of all registries.
37+
systemProperty 'forge.logging.markers', 'REGISTRIES'
38+
39+
// Recommended logging level for the console
40+
// You can set various levels here.
41+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
42+
systemProperty 'forge.logging.console.level', 'debug'
43+
44+
modSource project.sourceSets.main
45+
}
12446

125-
data {
126-
workingDirectory project.file('run')
47+
client {
48+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
49+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
50+
}
12751

128-
property 'forge.logging.markers', 'REGISTRIES'
52+
server {
53+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
54+
programArgument '--nogui'
55+
}
12956

130-
property 'forge.logging.console.level', 'debug'
57+
// This run config launches GameTestServer and runs all registered gametests, then exits.
58+
// By default, the server will crash when no gametests are provided.
59+
// The gametest system is also enabled by default for other run configs under the /test command.
60+
gameTestServer {
61+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
62+
}
13163

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

135-
mods {
136-
"${mod_id}" {
137-
source sourceSets.main
138-
}
139-
}
140-
}
68+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
69+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
14170
}
14271
}
14372

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

147-
repositories {
148-
// Put repositories for dependencies here
149-
// ForgeGradle automatically adds the Forge maven and Maven Central for you
150-
151-
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
152-
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
153-
// flatDir {
154-
// dir 'libs'
155-
// }
156-
}
15776

15877
dependencies {
15978
// Specify the version of Minecraft to use.
160-
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
161-
// The "userdev" classifier will be requested and setup by ForgeGradle.
162-
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
163-
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
164-
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
165-
166-
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
79+
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
80+
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
81+
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
82+
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
83+
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
84+
implementation "net.neoforged:neoforge:${neo_version}"
85+
86+
// Example mod dependency with JEI
16787
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
168-
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
169-
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
170-
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
88+
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
89+
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
90+
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
17191

17292
// Example mod dependency using a mod jar from ./libs with a flat dir repository
17393
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
17494
// The group id is ignored when searching -- in this case, it is "blank"
175-
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
95+
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
96+
97+
// Example mod dependency using a file as dependency
98+
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
99+
100+
// Example project dependency using a sister or child project:
101+
// implementation project(":myproject")
176102

177103
// For more info:
178104
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
@@ -183,57 +109,35 @@ dependencies {
183109
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
184110
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
185111
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
186-
def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta']
187-
def replaceProperties = [
188-
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
189-
forge_version: forge_version, forge_version_range: forge_version_range,
190-
loader_version_range: loader_version_range,
191-
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
192-
mod_authors: mod_authors, mod_description: mod_description
193-
]
194-
processResources {
112+
tasks.withType(ProcessResources).configureEach {
113+
var replaceProperties = [
114+
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
115+
neo_version : neo_version, neo_version_range: neo_version_range,
116+
loader_version_range: loader_version_range,
117+
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
118+
mod_authors : mod_authors, mod_description: mod_description, pack_format_number: pack_format_number,
119+
]
195120
inputs.properties replaceProperties
196-
replaceProperties.put 'project', project
197121

198-
filesMatching(resourceTargets) {
199-
expand replaceProperties
200-
}
201-
}
202-
203-
// Example for how to get properties into the manifest for reading at runtime.
204-
jar {
205-
manifest {
206-
attributes([
207-
"Specification-Title" : mod_id,
208-
"Specification-Vendor" : mod_authors,
209-
"Specification-Version" : "2", // We are version 1 of ourselves
210-
"Implementation-Title" : project.name,
211-
"Implementation-Version" : project.jar.archiveVersion,
212-
"Implementation-Vendor" : mod_authors,
213-
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
214-
])
122+
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
123+
expand replaceProperties + [project: project]
215124
}
216125
}
217126

218127
// Example configuration to allow publishing using the maven-publish plugin
219-
// This is the preferred method to reobfuscate your jar file
220-
jar.finalizedBy('reobfJar')
221-
// 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
222-
// publish.dependsOn('reobfJar')
223-
224128
publishing {
225129
publications {
226-
mavenJava(MavenPublication) {
227-
artifact jar
130+
register('mavenJava', MavenPublication) {
131+
from components.java
228132
}
229133
}
230134
repositories {
231135
maven {
232-
url "file://${project.projectDir}/mcmodsrepo"
136+
url "file://${project.projectDir}/repo"
233137
}
234138
}
235139
}
236140

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

gradle.properties

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
# This is required to provide enough memory for the Minecraft decompilation process.
33
org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
5-
5+
org.gradle.debug=false
66

77
## Environment Properties
88

9-
# The Minecraft version must agree with the Forge version to get a valid artifact
10-
minecraft_version=1.20.1
9+
# The Minecraft version must agree with the Neo version to get a valid artifact
10+
minecraft_version=1.20.2
1111
# The Minecraft version range can use any release version of Minecraft as bounds.
1212
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
1313
# as they do not follow standard versioning conventions.
14-
minecraft_version_range=[1.20,1.21)
15-
# The Forge version must agree with the Minecraft version to get a valid artifact
16-
forge_version=47.2.0
17-
# The Forge version range can use any version of Forge as bounds or match the loader version range
18-
forge_version_range=[46,)
19-
# The loader version range can only use the major version of Forge/FML as bounds
20-
loader_version_range=[46,)
14+
minecraft_version_range=[1.20.2,1.21)
15+
# The Neo version must agree with the Minecraft version to get a valid artifact
16+
neo_version=20.2.3-beta
17+
# The Neo version range can use any version of Neo as bounds or match the loader version range
18+
neo_version_range=[20.2,)
19+
# The loader version range can only use the major version of Neo/FML as bounds
20+
loader_version_range=[1,)
2121
# The mapping channel to use for mappings.
2222
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
2323
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
@@ -28,14 +28,14 @@ loader_version_range=[46,)
2828
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
2929
#
3030
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
31-
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
31+
# See more information here: https://github.com/neoforged/NeoForm/blob/main/Mojang.md
3232
#
3333
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
3434
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
35-
mapping_channel=parchment
35+
mapping_channel=official
3636
# The mapping version to query from the mapping channel.
3737
# This must match the format required by the mapping channel.
38-
mapping_version=2023.07.16-1.20.1
38+
mapping_version=1.20.2
3939

4040

4141
## Mod Properties
@@ -48,7 +48,7 @@ mod_name=Modular Materials
4848
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
4949
mod_license=LGPL-3.0
5050
# The mod version. See https://semver.org/
51-
mod_version=0.12-beta
51+
mod_version=0.13-beta
5252
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
5353
# This should match the base package used for the mod sources.
5454
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -57,3 +57,5 @@ mod_group_id=glowredman.modularmaterials
5757
mod_authors=glowredman
5858
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
5959
mod_description=Dynamic and fully customizeable material-generation-system for Minecraft 1.20
60+
# Pack version - this changes each minecraft release, in general.
61+
pack_format_number=18

0 commit comments

Comments
 (0)