Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
api:migration:neoforge [2023/11/17 04:20] – wip shedanielapi:migration:neoforge [2024/05/11 12:37] (current) – clarify file paths in forge-like section juuz
Line 1: Line 1:
 ====== NeoForge Migration ====== ====== NeoForge Migration ======
 Since an Architectury Loom 1.4 update, NeoForge 1.20.2 support has been introduced into Architectury. This page serves as a tutorial on how to migrate to NeoForge, depending on your current project, and your goals. The tutorials can be applied in reverse if needed. Since an Architectury Loom 1.4 update, NeoForge 1.20.2 support has been introduced into Architectury. This page serves as a tutorial on how to migrate to NeoForge, depending on your current project, and your goals. The tutorials can be applied in reverse if needed.
 +
 +__We assume the migration is not easy, please feel free to step by the Discord server for assistance.__
 +
 +== Acknowledgments ==
 +The bulk of the work on porting Architectury Loom is done by [[https://github.com/Juuxel|@Juuxel]].
  
 ==== About MinecraftForge ==== ==== About MinecraftForge ====
  
-To read more about our support on MinecraftForge and NeoForge, you may read more on the [[api:migration:version_10|migration page for 1.20.2]]. To summerize, we will continue to provide support for MinecraftForge and NeoForge's **toolchain** for the forseeable future. For Architectury API, we will prioritize compatibility for NeoForge over MinecraftForge in situations where it is impossible to maintain compatibility for both.+To learn more about our support on MinecraftForge and NeoForge, you may read on the [[api:migration:version_10|migration page for 1.20.2]]. To summerize, we will continue to provide support for MinecraftForge and NeoForge's **toolchain** for the forseeable future. For Architectury API, we will prioritize compatibility for NeoForge over MinecraftForge in situations where it is impossible to maintain compatibility for both. 
 + 
 +==== About Yarn ==== 
 + 
 +Architectury Loom had always supported Yarn as a mappings option for Forge, and will continue to do so for NeoForge. NeoForge has removed srg mappings as intermediary, such that both the development environment and production environment both use the same mappings.  
 + 
 +Architectury Loom 1.4 adds "hopes" and "prayers" (a joke, it is not actually that bad) to NeoForge in order to support Yarn. Remapping may not be done perfectly, so here are some things to take note. 
 + 
 +  - Write ATs in Mojang Mappings 
 +  - Don't use JS coremods 
 +  - Don't use reflection to access Minecraft internals (while we have a solution to remap reflection, it is not yet in Architectury Loom because we really **really** don't want to use it) 
 +  - MixinExtras may not function properly if you use Yarn (We have ditched refmaps for mixins, and our remapper is currently not capable of remapping MixinExtras)
  
 ===== Migrate your Forge-only project to NeoForge ===== ===== Migrate your Forge-only project to NeoForge =====
Line 31: Line 47:
  
 <code groovy> <code groovy>
-neoforge "net.neoforged:neoforge:VERSION"+neoForge "net.neoforged:neoforge:VERSION"
 </code> </code>
  
Line 63: Line 79:
   - Add a Forge-like subproject, and a NeoForge subproject   - Add a Forge-like subproject, and a NeoForge subproject
  
-===== Migrate your Forge subproject to NeoForge =====+==== Migrate your Forge subproject to NeoForge ====
  
 **1. Update to latest Gradle & Architectury Loom 1.4** **1. Update to latest Gradle & Architectury Loom 1.4**
Line 88: Line 104:
  
 <code groovy> <code groovy>
-neoforge "net.neoforged:neoforge:VERSION"+neoForge "net.neoforged:neoforge:VERSION"
 </code> </code>
 +
 +If you are using Architectury API, make sure to change ''architectury-forge'' to ''architectury-neoforge''.
  
 **6. Make sure your project's JavaCompile version is 17.** **6. Make sure your project's JavaCompile version is 17.**
Line 171: Line 189:
 **10. Refresh Gradle & Run Configs, Fix Errors & forge/META-INF/mods.toml & Profit??** **10. Refresh Gradle & Run Configs, Fix Errors & forge/META-INF/mods.toml & Profit??**
  
-===== Add a NeoForge subproject independent of the Forge subproject =====+==== Add a NeoForge subproject independent of the Forge subproject ====
  
 **1. Initial Setup** **1. Initial Setup**
  
-Create a ''neoforge'' folder, copy your ''forge'' folder's ''build.gradle'' and ''gradle.properties''.+Create a ''neoforge'' folder, and copy your ''forge'' folder's ''build.gradle'' and ''gradle.properties'' to it.
  
 Then in ''settings.gradle'', add ''include "neoforge"'' under the forge line. Then in ''settings.gradle'', add ''include "neoforge"'' under the forge line.
Line 183: Line 201:
 Follow the steps above in "Migrate your Forge subproject to NeoForge", but make sure you are applying to the ''neoforge'' project instead of the ''forge'' project. Follow the steps above in "Migrate your Forge subproject to NeoForge", but make sure you are applying to the ''neoforge'' project instead of the ''forge'' project.
  
-===== Add a Forge-like subproject, and a NeoForge subproject ===== +Also remember, in your ''common/build.gradle'', we want all three loaders in ''common()''
-WIP+ 
 +<code groovy> 
 +architectury { 
 +  common("fabric", "forge", "neoforge"
 +
 +</code> 
 + 
 +==== Add a Forge-like subproject, and a NeoForge subproject ==== 
 + 
 +**1. Initial Setup** 
 + 
 +  * Create a ''forgelike'' and ''neoforge'' folder. 
 +  * Copy your ''forge'' folder's ''build.gradle'' and ''gradle.properties'' to ''neoforge'' folder. 
 +  * Copy your ''common'' folder's ''build.gradle'' to ''forgelike'' folder 
 +  * Copy your ''forge'' folder's ''gradle.properties'' to ''forgelike'' folder. 
 +  * In ''settings.gradle'', add ''include "forgelike"'' above the forge line. 
 +  * In ''settings.gradle'', add ''include "neoforge"'' under the forge line. 
 + 
 +**2. Setup NeoForge** 
 + 
 +Follow the steps above in "Migrate your Forge subproject to NeoForge", but make sure you are applying to the ''neoforge'' project instead of the ''forge'' project. 
 + 
 +Make sure you do the "optional" platformPackage step, you most likely want to share packages between both. Also remember, in your ''common/build.gradle'', we want all three loaders in ''common()''
 + 
 +<code groovy> 
 +architectury { 
 +  common("fabric", "forge", "neoforge") { 
 +    it.platformPackage "neoforge", "forge" 
 +  } 
 +
 +</code> 
 + 
 + 
 + 
 +**3. Setup Forge-Like** 
 + 
 +In ''forgelike/build.gradle'', replace ''common()'' with ''forgeLike()'', and also apply ''platformPackage''
 +<code groovy> 
 +architectury { 
 +    forgeLike(["forge", "neoforge"]) { 
 +        it.platformPackage "neoforge", "forge" 
 +    } 
 +
 +</code> 
 + 
 +Then, remove the dependency on Fabric Loader, and add the dependency on MinecraftForge, and common, it should look like this: 
 + 
 +<code groovy> 
 +dependencies { 
 +  forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}" 
 +  compileOnly(project(path: ":common", configuration: "namedElements")) { transitive false } 
 +
 +</code> 
 + 
 +**4. Setup Forge** 
 + 
 +In ''forge/build.gradle'', add dependency to the forge-like project, the syntax should be equal to any other common projects. 
 + 
 +<code groovy> 
 +dependencies { 
 +  forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}" 
 + 
 +  common(project(path: ":common", configuration: "namedElements")) { transitive false } 
 +  common(project(path: ":forgelike", configuration: "namedElements")) { transitive false } 
 +  shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } 
 +  shadowCommon(project(path: ":forgelike", configuration: "transformProductionForge")) { transitive false } 
 +
 +</code> 
 + 
 +**5. Setup NeoForge** 
 + 
 +First, we need to add the forgeLike configuration, then we extend compile/runtimeClasspath on it, like how we do it for common. We will also extend developmentForgeLike on our configuration. 
 + 
 +<code groovy> 
 +configurations { 
 +  common 
 +  forgeLike 
 +  shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. 
 +  compileClasspath.extendsFrom common, forgeLike 
 +  runtimeClasspath.extendsFrom common, forgeLike 
 +  developmentNeoForge.extendsFrom common 
 +  developmentForgeLike.extendsFrom forgeLike 
 +
 +</code> 
 + 
 +Then, similar to above, we will add the dependency on Forge-Like's project. You will notice how we are using ''transformProductionNeoForge'' instead of ''transformProductionForge'' and ''forgeLike'' instead of ''common'' only on the forgelike project. 
 + 
 +<code groovy> 
 +dependencies { 
 +  neoforge "net.neoforged:neoforge:${rootProject.neoforge_version}" 
 + 
 +  common(project(path: ":common", configuration: "namedElements")) { transitive false } 
 +  forgeLike(project(path: ":forgelike", configuration: "namedElements")) { transitive false } 
 +  shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive false } 
 +  shadowCommon(project(path: ":forgelike", configuration: "transformProductionNeoForge")) { transitive false } 
 +
 +</code> 
 + 
 +**6. Setup NeoForge remaps** 
 + 
 +Since there are class renames in NeoForge, we will want to remap them. Architectury Plugin automatically added remaps to NeoForge's packages, and the ''MinecraftForge'' -> ''NeoForge'' class, but you will need to do the rest. 
 + 
 +Here's an example on remapping ''IForgeItem'' to ''IItemExtension''
 + 
 +<code groovy> 
 +// In forgelike/build.gradle 
 +architectury { 
 +  forgeLike(["forge", "neoforge"]) { 
 +    it.platformPackage "neoforge", "forge" 
 +    it.remapForgeLike "net/minecraftforge/common/extensions/IForgeItem", "net/neoforged/neoforge/common/extensions/IItemExtension" 
 +  } 
 +
 + 
 +// In neoforge/build.gradle 
 +architectury { 
 +  neoForge { 
 +    platformPackage "forge" 
 +    remapForgeLike "net/minecraftforge/common/extensions/IForgeItem", "net/neoforged/neoforge/common/extensions/IItemExtension" 
 +  } 
 +} 
 +</code>