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:34] shedanielapi:migration:neoforge [2024/05/11 12:37] (current) – clarify file paths in forge-like section juuz
Line 3: Line 3:
  
 __We assume the migration is not easy, please feel free to step by the Discord server for assistance.__ __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 ==== ==== About Yarn ====
Line 12: Line 15:
 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 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" to NeoForge in order to support Yarn. Remapping may not be done perfectly, so here's a few things to take note.+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   - Write ATs in Mojang Mappings
Line 190: Line 193:
 **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 197: Line 200:
  
 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.
 +
 +Also remember, in your ''common/build.gradle'', we want all three loaders in ''common()''.
 +
 +<code groovy>
 +architectury {
 +  common("fabric", "forge", "neoforge")
 +}
 +</code>
  
 ==== Add a Forge-like subproject, and a NeoForge subproject ==== ==== Add a Forge-like subproject, and a NeoForge subproject ====
-WIP+ 
 +**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>