Sebastian Hartte 171947d601 Port to 1.21.11-pre3
Co-authored-by: Matyrobbrt <matyrobbrt@gmail.com>
Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com>
Co-authored-by: TelepathicGrunt <40846040+TelepathicGrunt@users.noreply.github.com>
Co-authored-by: XFactHD <xfacthd@gmx.de>
2025-12-08 22:04:59 +01:00
..
2025-12-08 22:04:59 +01:00

NeoForge Development Gradle Plugin

NeoForge Project Structure

Before understanding the buildSrc plugin, one should understand the structure of the NeoForge Gradle project it is applied to.

The project consists of a project tree with the following structure:

Folder Path Gradle Project Path Applied Plugins Description
/build.gradle : The root project. Since this project is reused for Kits, the root project name is based on the checkout folder, which actually can lead to issues if it is called NeoForge.
/projects/neoforge/build.gradle :neoforge NeoDevPlugin The core NeoForge project, which produces the artifacts that will be published.
/projects/base/build.gradle :base NeoDevBasePlugin A utility project that contains the Minecraft sources without any NeoForge additions. Can be used to quickly compare what NeoForge has changed.
/tests/build.gradle :tests NeoDevExtraPlugin Contains the game and unit tests for NeoForge.
/testframework/build.gradle :testframework MinecraftDependenciesPlugin A library providing support classes around writing game tests.
/coremods/build.gradle :neoforge-coremods Java Bytecode transformers that are embedded into NeoForge as a nested Jar file.

Plugins

NeoDevBasePlugin

Sources: NeoDevBasePlugin.java

Implicitly applies: MinecraftDependenciesPlugin.

Sets up a setup task that reuses code from NeoDevPlugin to decompile Minecraft and place the decompiled sources in projects/base/src/main/java.

NeoDevPlugin

Sources: NeoDevPlugin.java

Implicitly applies: MinecraftDependenciesPlugin.

This is the primary of this repository and is used to configure the neoforge subproject.

Setup

It creates a setup task that performs the following actions via various subtasks:

  • Decompile Minecraft using the NeoForm Runtime and Minecraft version specific NeoForm data.
  • Applies Access Transformers to Minecraft sources.
  • Applies NeoForge patches to Minecraft sources. Any rejects are saved to the /rejects folder in the repository for manual inspection. During updates to new versions, the task can be run with -Pupdating=true to apply patches more leniently.
  • Unpacks the patched sources to projects/neoforge/src/main/java.

Config Generation

The plugin creates and configures the tasks to create various configuration files used downstream to develop mods with this version of NeoForge (CreateUserDevConfig), or install it (CreateInstallerProfile and CreateLauncherProfile).

A separate userdev profile is created for use by other subprojects in this repository. The only difference is that it uses the FML launch types ending in dev rather than userdev.

Patch Generation

NeoForge injects its hooks into Minecraft by patching the decompiled source code. Changes are made locally to the decompiled and patched source. Since that source cannot be published, patches need to be generated before checking in. The plugin configures the necessary task to do this (GenerateSourcePatches).

The source patches are only used during development of NeoForge itself and development of mods that use Gradle plugins implementing the decompile/patch/recompile pipeline. For use by the installer intended for players as well as Gradle plugins wanting to replicate the production artifacts more closely, binary patches are generated using the (GenerateBinaryPatches) task.

NeoDevExtraPlugin

Sources: NeoDevExtraPlugin.java

This plugin can be applied to obtain a dependency on the neoforge project to depend on NeoForge including Minecraft itself. Besides wiring up the dependency, it also creates run configurations based on the run-types defined in the neoforge project.

MinecraftDependenciesPlugin

This plugin is reused from ModDevGradle.

It sets up repositories and attributes such that the libraries that Minecraft itself depends upon can be used.