Forked from jaredlll08/MultiLoader-Template
This fork does not aim to achieve comprehensive cross-version compatibility that would let you instantly switch versions even when the toolchain introduces breaking changes.
Instead, it strives to make the most of existing toolchain capabilities with minimal invasive modifications to the original template, enabling you to develop across a wider range of versions as long as Mojang or the toolchain do not introduce breaking changes.This means it works best for maintaining a mod across multiple patch versions of the same major Minecraft release, or between releases where the toolchain hasn't introduced breaking changes. It won't magically bridge the vast gap in toolchains between distant versions like 1.16 and 1.21, where the build system and loader setups have shifted dramatically.
This is a customized fork of the original MultiLoader Template.
For full documentation, setup instructions, and general usage, please refer to the
original README.
This version introduces the following changes to support easier multi‑version and multi‑loader configuration:
-
Centralized Version Configuration
- Set the target Minecraft version in
gradle.propertiesunderminecraft_version. - Add a corresponding
${minecraft_version}.propertiesfile inside theversionsdirectory for version‑specific settings.
- Set the target Minecraft version in
-
Conditional Loader Subproject Inclusion
- The build automatically includes or excludes loader‑specific subprojects (Fabric, NeoForge, Forge) based on the
corresponding property (
fabric_version,neoforge_version,forge_version) defined in the${minecraft_version}.propertiesfile. - A loader subproject is excluded when its property is explicitly set to
"null"(as a string).
Example:fabric_version=nullwill exclude the Fabric subproject for that Minecraft version.
- The build automatically includes or excludes loader‑specific subprojects (Fabric, NeoForge, Forge) based on the
corresponding property (
-
Manifold Preprocessor Support
- Added the dependency
systems.manifold:manifold-preprocessorto enable conditional compilation based on Minecraft versions. - In your source code, you can now use the following syntax:
#if MC1_21 // Code that only compiles for Minecraft 1.21 (exact two‑segment version) #endif #if MC1_21_1 // Code that only compiles for Minecraft 1.21.1 #endif #if MC1_21_X // Code that compiles for all Minecraft 1.21.x versions (e.g. 1.21, 1.21.1, 1.21.2 …) #endif
- The preprocessor directives are determined automatically from the
minecraft_versionproperty:- Two‑segment versions (e.g.
1.21) define bothMC1_21and the wildcardMC1_21_X. - Three‑segment versions (e.g.
1.21.1) defineMC1_21_1and the wildcardMC1_21_X.
(For three‑segment versions, the plainMCmajor_minorform likeMC1_21is not defined.) - Non‑standard versions (snapshots, pre‑releases like
1.21-rc1) define only a sanitized form (e.g.MC1_21_RC1). Wildcard preprocessing (such asMC1_21_X) is not available for these versions.
- Two‑segment versions (e.g.
- This allows you to write version‑specific code blocks that are automatically included or excluded during
compilation based on the target
minecraft_version. Use the_Xwildcard to match an entire minor release family when your code is compatible across all patches of that family.
- Added the dependency
-
JUnit 5 Testing Support
- Added
org.junit.jupiter:junit-jupiteras a common test dependency, so unit tests can be written and executed across all loader subprojects out of the box.
- Added
These adjustments provide more explicit control over loader inclusion and enable powerful conditional compilation for multi‑version support, while maintaining compatibility with the original template structure.