-
-
Notifications
You must be signed in to change notification settings - Fork 27
Legacy plugin for 1.17 to 1.20.1 #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b13edf5
Add legacy support for Forge 1.17 to 1.20.1
shartte d18176f
Post-rebase fixes
shartte f4d21ac
Bump Gradle
shartte 8008201
Add foojay
shartte c02903a
Bump Gradle
shartte 9a71054
Move launch scripts back to old approach and make them sync no more
shartte 9e2275a
Fix deprecation
shartte bf1b6df
Review comments
shartte 8d22d52
More internal, moved to internal/dsl packages
shartte 36800dd
More internal, moved to internal/dsl packages
shartte 84a82bc
Review comment
shartte 1e1752a
Review comments
shartte def3521
Review comments
shartte aacf6cb
Review comments
shartte d7b5f77
Review comments
shartte 25a4bb7
Review comments
shartte 72143fe
Review comments
shartte 272eb66
Review comments
shartte f586cdd
Review comments
shartte 13a0a6b
Review comments
shartte 1baf59e
call publishing as part of running the tests
shartte 45f57d8
Review comments
shartte 46172f3
Review comments
shartte eebbfd7
Review comments
shartte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # ModDevGradle Legacy Forge Plugin | ||
| ModDevGradle has a secondary plugin (ID: `net.neoforged.moddev.legacyforge`, released alongside the normal plugin with the same version) | ||
| that adds support for developing mods against MinecraftForge and Vanilla Minecraft versions 1.17 up to 1.20.1. | ||
|
|
||
| The legacy plugin is an "addon" plugin, meaning it operates on top of the normal plugin. This means that the APIs normally used | ||
| are also available when using the legacy plugin. | ||
|
|
||
| ## Basic Usage for MinecraftForge Mods | ||
| An example `build.gradle` file for developing a mod against MinecraftForge for 1.20.1 is provided below: | ||
| ```groovy | ||
| plugins { | ||
| // Apply the plugin. You can find the latest version at https://projects.neoforged.net/neoforged/ModDevGradle | ||
| id 'net.neoforged.moddev.legacyforge' version '2.0.28-beta' | ||
| } | ||
|
|
||
| neoForge { | ||
| // Develop against MinecraftForge version 47.3.0 for 1.20.1 (the versions can be found at https://files.minecraftforge.net/) | ||
| version = "1.20.1-47.3.0" | ||
|
|
||
| // Validate AT files and raise errors when they have invalid targets | ||
| // This option is false by default, but turning it on is recommended | ||
| validateAccessTransformers = true | ||
|
|
||
| runs { | ||
| client { | ||
| client() | ||
| } | ||
| data { | ||
| data() | ||
| } | ||
| server { | ||
| server() | ||
| } | ||
| } | ||
|
|
||
| mods { | ||
| testproject { | ||
| sourceSet sourceSets.main | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Reobfuscating artifacts | ||
| Forge used SRG mappings as intermediary mappings in 1.20.1 and below. While your mod is developed against the mappings provided | ||
| by Mojang (known as official mappings), you need to reobfuscate it to SRG mappings for it to work in production. | ||
| Reobfuscation will automatically be configured for the `jar` task; the non-obfuscated jar will have a `-dev` classifier | ||
| and will not be published in favour of the reobfuscated variant. You should upload the `reobfJar` task's output when using a | ||
| task to upload to a mod hosting platform, or otherwise the jar without a `-dev` classifier if you're uploading it manually. | ||
|
|
||
| You may reobfuscate other jar tasks using `obfuscation.reobfuscate(TaskProvider<AbstractArchiveTask>, SourceSet, Action<RemapJarTask>)`. | ||
| For instance, if you want to reobfuscate a `shadowJar` task: | ||
| ```groovy | ||
| shadowJar { | ||
| // Change the classifier of the shadow jar to be -dev-all as it's not mapped in intermediary and not usable for production | ||
| archiveClassifier = 'dev-all' | ||
| } | ||
|
|
||
| obfuscation { | ||
| // Reobfuscate the shadowJar task, using the classpath of the main sourceset for properly remapping inherited members | ||
| reobfuscate(tasks.named('shadowJar'), sourceSets.main) { | ||
| // Make the reobfuscated shadowJar have the all classifier | ||
| // You could also change it to an empty string if you want it to not have a classifier (in that case, you will also need to change the classifier of the slim `reobfJar` task | ||
| archiveClassifier = 'all' | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| When reobfuscating a jar, it will be replaced in publications with the obfuscated version to avoid publishing jars that aren't mapped to SRG. | ||
|
|
||
| ## Remapping mod dependencies | ||
| As published mods are using intermediary mappings, you must remap them to official mappings before being able to use them as a dependencies. | ||
| ModDevGradle creates configurations that will automatically remap dependencies added to them from SRG mappings to official mappings. | ||
| The following configurations are created automatically and are children of the configurations without the `mod` prefix: | ||
| - `modImplementation` | ||
| - `modRuntimeOnly` | ||
| - `modCompileOnly` | ||
| - `modApi` (only if the `java-library` plugin is applied) | ||
| - `modCompileOnlyApi` (only if the `java-library` plugin is applied) | ||
|
|
||
| You may create your own remapping configurations using `obfuscation.createRemappingConfiguration(Configuration)`: | ||
| ```groovy | ||
| configurations { | ||
| // Create a custom configuration named "custom" | ||
| custom | ||
| } | ||
|
|
||
| obfuscation { | ||
| // Create a configuration named "modCustom" that remaps its dependencies and then adds them to the "custom" configuration | ||
| createRemappingConfiguration(configurations.custom) | ||
| } | ||
| ``` | ||
|
|
||
| ## Effects of applying the legacy plugin | ||
| When applied, the legacy plugin will change the base NeoForm and NeoForge artifact coordinates of the `neoForge` extension to | ||
| `de.oceanlabs.mcp:mcp_config` and `net.minecraftforge:forge`. | ||
| It will also trigger the creation of various intermediary (SRG) to named (official) mapping files used by various parts of the toolchain, such as | ||
| mod reobfuscation and runtime naming services. | ||
| Reobfuscation to the intermediary mappings will automatically be configured for the `jar` task, the non-obfuscated jar will have a `-dev` classifier | ||
| and will not be published in favour of the reobfuscated variant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| run/ | ||
| repo/ | ||
| *.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| plugins { | ||
| id 'maven-publish' | ||
| id 'net.neoforged.moddev.legacyforge' | ||
| } | ||
|
|
||
| group = 'com.example.legacy' | ||
| version = '1.0.0' | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(17) | ||
| } | ||
| } | ||
|
|
||
| neoForge { | ||
| neoFormVersion = '1.19.2' | ||
| } | ||
|
|
||
| publishing { | ||
| publications { | ||
| maven(MavenPublication) { | ||
| from components.java | ||
| } | ||
| } | ||
| repositories { | ||
| maven { | ||
| url file('local') | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| plugins { | ||
| id 'net.neoforged.moddev.legacyforge' | ||
| id 'maven-publish' | ||
| } | ||
|
|
||
| repositories { | ||
| mavenLocal() | ||
| maven { | ||
| name = "Jared's maven" | ||
| url = "https://maven.blamejared.com/" | ||
| } | ||
| maven { | ||
| name 'cursemaven' | ||
| url 'https://cursemaven.com' | ||
| content { | ||
| includeGroup "curse.maven" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(17) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| modCompileOnly('mezz.jei:jei-1.20.1-forge:15.17.0.76') { | ||
| transitive = false // JEI publishes dependencies on its subprojects that are already included in this Jar | ||
| } | ||
| modRuntimeOnly('curse.maven:mekanism-268560:5662583') | ||
| modImplementation('curse.maven:applied-energistics-2-223794:5641282') | ||
| // This is an example for a mod that does NOT work with FG or MDG since its JiJ dependencies are | ||
| // packages into /META-INF/jars while installertools will only remap /META-INF/jarjar/*.jar | ||
| // modImplementation('curse.maven:gregtechceu-modern-890405:5641637') | ||
| } | ||
|
|
||
| neoForge { | ||
| version = '1.20.1-47.3.0' | ||
| runs { | ||
| client { | ||
| client() | ||
| } | ||
| data { | ||
| data() | ||
| } | ||
| } | ||
| mods { | ||
| myMod { | ||
| sourceSet(sourceSets.main) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| publishing { | ||
| publications { | ||
| maven(MavenPublication) { | ||
| from components.java | ||
| } | ||
| } | ||
| repositories { | ||
| maven { | ||
| url rootProject.file('repo') | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package mymod; | ||
|
|
||
| import mezz.jei.api.IModPlugin; | ||
| import mezz.jei.api.JeiPlugin; | ||
| import mezz.jei.api.registration.ISubtypeRegistration; | ||
| import net.minecraft.resources.ResourceLocation; | ||
| import net.minecraft.world.item.Items; | ||
|
|
||
| @JeiPlugin | ||
| public class JeiCompat implements IModPlugin { | ||
| @Override | ||
| public ResourceLocation getPluginUid() { | ||
| return new ResourceLocation("mymod:mymod"); | ||
| } | ||
|
|
||
| @Override | ||
| public void registerItemSubtypes(ISubtypeRegistration registration) { | ||
| // Calling this method tests that JEI was remapped correctly, since the method has an "ItemStack" argument | ||
| registration.registerSubtypeInterpreter(Items.ALLIUM, (ingredient, context) -> "allium"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package mymod; | ||
|
|
||
| import net.minecraftforge.fml.common.Mod; | ||
|
|
||
| @Mod("mymod") | ||
| public class MyMod { | ||
| public void run() { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| modLoader="javafml" #mandatory | ||
| loaderVersion="*" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. | ||
| license="ARR" | ||
| [[mods]] #mandatory | ||
| # The modid of the mod | ||
| modId="mymod" #mandatory | ||
| # The version number of the mod | ||
| version="1.0" #mandatory | ||
| # A display name for the mod | ||
| displayName="My Mod" #mandatory | ||
| authors="MDG" #optional | ||
| description='''Hi.''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.gradle.configuration-cache=true |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip | ||
| networkTimeout=10000 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.