Skip to content

Commit 0cb1ba6

Browse files
committed
1.20.1 MDK using MDG Legacy
1 parent d55eb06 commit 0cb1ba6

File tree

8 files changed

+132
-127
lines changed

8 files changed

+132
-127
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean`
1414

1515
Mapping Names:
1616
============
17-
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
17+
The MDK is configured to use the official mapping names from Mojang for methods and fields
1818
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
1919
license. For the latest license text, refer to the mapping file itself, or the reference copy here:
2020
https://github.com/NeoForged/NeoForm/blob/main/Mojang.md
2121

22+
MDG Legacy:
23+
==========
24+
This template uses [ModDevGradle Legacy](https://github.com/neoforged/ModDevGradle). Documentation can be found [here](https://github.com/neoforged/ModDevGradle/blob/main/LEGACY.md).
25+
2226
Additional Resources:
2327
==========
2428
Community Documentation: https://docs.neoforged.net/

build.gradle

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'idea'
33
id 'java-library'
44
id 'maven-publish'
5-
id 'net.neoforged.moddev' version '1.0.23'
5+
id 'net.neoforged.moddev.legacyforge' version '2.0.76'
66
}
77

88
tasks.named('wrapper', Wrapper).configure {
@@ -25,12 +25,12 @@ base {
2525
archivesName = mod_id
2626
}
2727

28-
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
29-
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
28+
// Mojang ships Java 21 to end users in 1.20.1, so mods should target Java 17.
29+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
3030

31-
neoForge {
32-
// Specify the version of NeoForge to use.
33-
version = project.neo_version
31+
legacyForge {
32+
// Specify the version of MinecraftForge to use.
33+
version = project.minecraft_version + '-' + project.forge_version
3434

3535
parchment {
3636
mappingsVersion = project.parchment_mappings_version
@@ -47,21 +47,21 @@ neoForge {
4747
client()
4848

4949
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
50-
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
50+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
5151
}
5252

5353
server {
5454
server()
5555
programArgument '--nogui'
56-
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
56+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
5757
}
5858

5959
// This run config launches GameTestServer and runs all registered gametests, then exits.
6060
// By default, the server will crash when no gametests are provided.
6161
// The gametest system is also enabled by default for other run configs under the /test command.
6262
gameTestServer {
6363
type = "gameTestServer"
64-
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
64+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
6565
}
6666

6767
data {
@@ -104,53 +104,77 @@ neoForge {
104104
// Include resources generated by data generators.
105105
sourceSets.main.resources { srcDir 'src/generated/resources' }
106106

107-
// Sets up a dependency configuration called 'localRuntime'.
108-
// This configuration should be used instead of 'runtimeOnly' to declare
107+
// Sets up a dependency configuration called 'localRuntime' and a deobfuscating one called 'modLocalRuntime'
108+
// These configurations should be used instead of 'runtimeOnly' to declare
109109
// a dependency that will be present for runtime testing but that is
110110
// "optional", meaning it will not be pulled by dependents of this mod.
111111
configurations {
112112
runtimeClasspath.extendsFrom localRuntime
113113
}
114+
obfuscation {
115+
createRemappingConfiguration(configurations.localRuntime)
116+
}
114117

115118
dependencies {
119+
// If you wish to declare dependencies against mods, make sure to use the 'mod*' configurations so that they're remapped.
120+
// See https://github.com/neoforged/ModDevGradle/blob/main/LEGACY.md#remapping-mod-dependencies for more information.
121+
116122
// Example optional mod dependency with JEI
117123
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
118-
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
119-
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
124+
// modCompileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
125+
// modCompileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
120126
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
121-
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
127+
// modLocalRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
122128

123129
// Example mod dependency using a mod jar from ./libs with a flat dir repository
124130
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
125131
// The group id is ignored when searching -- in this case, it is "blank"
126-
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
132+
// modImplementation "blank:coolmod-${mc_version}:${coolmod_version}"
127133

128134
// Example mod dependency using a file as dependency
129-
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
135+
// modImplementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
130136

131137
// Example project dependency using a sister or child project:
132-
// implementation project(":myproject")
138+
// modImplementation project(":myproject")
133139

134140
// For more info:
135141
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
136142
// http://www.gradle.org/docs/current/userguide/dependency_management.html
137143
}
138144

145+
// Uncomment the lines below if you wish to configure mixin. The mixin file should be named modid.mixins.json.
146+
/*
147+
mixin {
148+
add sourceSets.main, "${mod_id}.refmap.json"
149+
config "${mod_id}.mixins.json"
150+
}
151+
152+
dependencies {
153+
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
154+
}
155+
156+
jar {
157+
manifest.attributes([
158+
"MixinConfigs": "${mod_id}.mixins.json"
159+
])
160+
}
161+
*/
162+
139163
// This block of code expands all declared replace properties in the specified resource targets.
140164
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
141165
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
142166
var replaceProperties = [
143-
minecraft_version : minecraft_version,
144-
minecraft_version_range: minecraft_version_range,
145-
neo_version : neo_version,
146-
neo_version_range : neo_version_range,
147-
loader_version_range : loader_version_range,
148-
mod_id : mod_id,
149-
mod_name : mod_name,
150-
mod_license : mod_license,
151-
mod_version : mod_version,
152-
mod_authors : mod_authors,
153-
mod_description : mod_description
167+
minecraft_version : minecraft_version,
168+
minecraft_version_range : minecraft_version_range,
169+
forge_version : forge_version,
170+
forge_version_range : forge_version_range,
171+
loader_version_range : loader_version_range,
172+
mod_id : mod_id,
173+
mod_name : mod_name,
174+
mod_license : mod_license,
175+
mod_version : mod_version,
176+
mod_authors : mod_authors,
177+
mod_description : mod_description
154178
]
155179
inputs.properties replaceProperties
156180
expand replaceProperties
@@ -161,7 +185,7 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources
161185
// this works with both building through Gradle and the IDE.
162186
sourceSets.main.resources.srcDir generateModMetadata
163187
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
164-
neoForge.ideSyncTask generateModMetadata
188+
legacyForge.ideSyncTask generateModMetadata
165189

166190
// Example configuration to allow publishing using the maven-publish plugin
167191
publishing {

gradle.properties

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ org.gradle.configuration-cache=true
77

88
#read more on this at https://github.com/neoforged/ModDevGradle?tab=readme-ov-file#better-minecraft-parameter-names--javadoc-parchment
99
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
10-
parchment_minecraft_version=1.21.1
11-
parchment_mappings_version=2024.11.17
10+
parchment_minecraft_version=1.20.1
11+
parchment_mappings_version=2023.09.03
1212
# Environment Properties
13-
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
14-
# The Minecraft version must agree with the Neo version to get a valid artifact
15-
minecraft_version=1.21.1
13+
# You can find the latest versions here: https://files.minecraftforge.net/net/minecraftforge/forge/index_1.20.1.html
14+
# The Minecraft version must agree with the Forge version to get a valid artifact
15+
minecraft_version=1.20.1
1616
# The Minecraft version range can use any release version of Minecraft as bounds.
1717
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
1818
# as they do not follow standard versioning conventions.
19-
minecraft_version_range=[1.21.1, 1.22)
20-
# The Neo version must agree with the Minecraft version to get a valid artifact
21-
neo_version=21.1.114
22-
# The Neo version range can use any version of Neo as bounds
23-
neo_version_range=[21.1.0,)
19+
minecraft_version_range=[1.20.1, 1.21)
20+
# The Forge version must agree with the Minecraft version to get a valid artifact
21+
forge_version=47.1.3
22+
# The Forge version range can use any version of Forge as bounds
23+
forge_version_range=[47.1.3,)
2424
# The loader version range can only use the major version of FML as bounds
25-
loader_version_range=[4,)
25+
loader_version_range=[47,)
2626

2727
## Mod Properties
2828

settings.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
pluginManagement {
2-
repositories {
3-
mavenLocal()
4-
gradlePluginPortal()
5-
maven { url = 'https://maven.neoforged.net/releases' }
6-
}
7-
}
8-
91
plugins {
102
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
113
}
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
package com.example.examplemod;
22

3-
import java.util.List;
4-
import java.util.Set;
5-
import java.util.stream.Collectors;
6-
73
import net.minecraft.core.registries.BuiltInRegistries;
84
import net.minecraft.resources.ResourceLocation;
95
import net.minecraft.world.item.Item;
10-
import net.neoforged.bus.api.SubscribeEvent;
11-
import net.neoforged.fml.common.EventBusSubscriber;
12-
import net.neoforged.fml.event.config.ModConfigEvent;
13-
import net.neoforged.neoforge.common.ModConfigSpec;
6+
import net.minecraftforge.common.ForgeConfigSpec;
7+
import net.minecraftforge.eventbus.api.SubscribeEvent;
8+
import net.minecraftforge.fml.common.Mod;
9+
import net.minecraftforge.fml.event.config.ModConfigEvent;
10+
11+
import java.util.List;
12+
import java.util.Set;
13+
import java.util.stream.Collectors;
1414

1515
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
16-
// Demonstrates how to use Neo's config APIs
17-
@EventBusSubscriber(modid = ExampleMod.MODID, bus = EventBusSubscriber.Bus.MOD)
16+
// Demonstrates how to use Forge's config APIs
17+
@Mod.EventBusSubscriber(modid = ExampleMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
1818
public class Config
1919
{
20-
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
20+
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
2121

22-
private static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
22+
private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
2323
.comment("Whether to log the dirt block on common setup")
2424
.define("logDirtBlock", true);
2525

26-
private static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER
26+
private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
2727
.comment("A magic number")
2828
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
2929

30-
public static final ModConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
30+
public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
3131
.comment("What you want the introduction message to be for the magic number")
3232
.define("magicNumberIntroduction", "The magic number is... ");
3333

3434
// a list of strings that are treated as resource locations for items
35-
private static final ModConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
35+
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
3636
.comment("A list of items to log on common setup.")
3737
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName);
3838

39-
static final ModConfigSpec SPEC = BUILDER.build();
39+
static final ForgeConfigSpec SPEC = BUILDER.build();
4040

4141
public static boolean logDirtBlock;
4242
public static int magicNumber;
@@ -45,7 +45,7 @@ public class Config
4545

4646
private static boolean validateItemName(final Object obj)
4747
{
48-
return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName));
48+
return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(new ResourceLocation(itemName));
4949
}
5050

5151
@SubscribeEvent
@@ -57,7 +57,7 @@ static void onLoad(final ModConfigEvent event)
5757

5858
// convert the list of strings into a set of items
5959
items = ITEM_STRINGS.get().stream()
60-
.map(itemName -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(itemName)))
60+
.map(itemName -> BuiltInRegistries.ITEM.get(new ResourceLocation(itemName)))
6161
.collect(Collectors.toSet());
6262
}
6363
}

0 commit comments

Comments
 (0)