diff --git a/README.md b/README.md index 4460141..88de773 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,27 @@ # MultiLoader Template -This project provides a Gradle project template that can compile mods for both Forge and Fabric using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join our [Discord](https://discord.myceliummod.network). +This project provides a Gradle project template that can compile mods for multiple modloaders using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join our [Discord](https://discord.myceliummod.network). ## Getting Started ### IntelliJ IDEA -This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up Forge and Fabric independently and should be very familiar to anyone who has worked with their MDKs. +This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up the modloaders independently and should be very familiar to anyone who has worked with their MDKs. 1. Clone or download this repository to your computer. 2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`, this should match the folder name of your project, or else IDEA may complain. 3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. -4. If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. +4. If your default JVM/JDK is not Java 21 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM` and changing the value to a valid Java 21 JVM. You will also need to set the Project SDK to Java 21. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. 5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. -6. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge. -7. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it. -8. Assuming you were able to run the game in step 7 your workspace should now be set up. +6. Open your Run/Debug Configurations. Under the Application category there should now be options to run NeoForge and Fabric projects. Select one of the client options and try to run it. +7. Assuming you were able to run the game in step 7 your workspace should now be set up. ### Eclipse While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available. ## Development Guide -When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project. +When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the NeoForge or Fabric project. -Loader specific projects such as the Forge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects. +Loader specific projects such as the NeoForge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects. ## Removing Platforms and Loaders While the MultiLoader Template includes support for many platforms and loaders you can easily remove support for the ones you don't need. This can be done by deleting the subproject folder and then removing it from the `settings.gradle` file. For example if you wanted to remove support for Forge you would follow the following steps. diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle index 70c3e0d..012eb1a 100644 --- a/buildSrc/src/main/groovy/multiloader-common.gradle +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -76,9 +76,6 @@ processResources { "version": version, "group": project.group, //Else we target the task's group. "minecraft_version": minecraft_version, - "forge_version": forge_version, - "forge_loader_version_range": forge_loader_version_range, - "forge_version_range": forge_version_range, "minecraft_version_range": minecraft_version_range, "fabric_version": fabric_version, "fabric_loader_version": fabric_loader_version, diff --git a/common/src/main/resources/examplemod.mixins.json b/common/src/main/resources/examplemod.mixins.json index 71b5c4c..0735c74 100644 --- a/common/src/main/resources/examplemod.mixins.json +++ b/common/src/main/resources/examplemod.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "com.example.examplemod.mixin", "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "MixinMinecraft" diff --git a/fabric/src/main/resources/examplemod.fabric.mixins.json b/fabric/src/main/resources/examplemod.fabric.mixins.json index b8d1f95..5abf2d7 100644 --- a/fabric/src/main/resources/examplemod.fabric.mixins.json +++ b/fabric/src/main/resources/examplemod.fabric.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "com.example.examplemod.mixin", "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "MixinTitleScreen" diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index bbee235..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,87 +0,0 @@ -plugins { - id 'multiloader-loader' - id 'net.minecraftforge.gradle' version '[6.0,6.2)' - id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' -} -base { - archivesName = "${mod_name}-forge-${minecraft_version}" -} -mixin { - add(sourceSets.main, "${mod_id}.refmap.json") - - config("${mod_id}.mixins.json") - config("${mod_id}.forge.mixins.json") -} - -minecraft { - mappings channel: 'official', version: minecraft_version - - copyIdeResources = true //Calls processResources when in dev - - // Automatically enable forge AccessTransformers if the file exists - // This location is hardcoded in Forge and can not be changed. - // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 - def at = file('src/main/resources/META-INF/accesstransformer.cfg') - if (at.exists()) { - accessTransformer = at - } - - runs { - client { - workingDirectory file('runs/client') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Client' - mods { - modClientRun { - source sourceSets.main - } - } - } - - server { - workingDirectory file('runs/server') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Server' - mods { - modServerRun { - source sourceSets.main - } - } - } - - data { - workingDirectory file('runs/data') - ideaModule "${rootProject.name}.${project.name}.main" - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - taskName 'Data' - mods { - modDataRun { - source sourceSets.main - } - } - } - } -} - -sourceSets.main.resources.srcDir 'src/generated/resources' - -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") -} - -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava(MavenPublication) { - fg.component(it) - } - } -} - -sourceSets.each { - def dir = layout.buildDirectory.dir("sourcesSets/$it.name") - it.output.resourcesDir = dir - it.java.destinationDirectory = dir -} \ No newline at end of file diff --git a/forge/src/main/java/com/example/examplemod/ExampleMod.java b/forge/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index 06f3628..0000000 --- a/forge/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.examplemod; - -import net.minecraftforge.fml.common.Mod; - -@Mod(Constants.MOD_ID) -public class ExampleMod { - - public ExampleMod() { - - // This method is invoked by the Forge mod loader when it is ready - // to load your mod. You can access Forge and Common code in this - // project. - - // Use Forge to bootstrap the Common mod. - Constants.LOG.info("Hello Forge world!"); - CommonClass.init(); - - } -} \ No newline at end of file diff --git a/forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java b/forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java deleted file mode 100644 index a2e0c4b..0000000 --- a/forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.examplemod.mixin; - -import com.example.examplemod.Constants; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.TitleScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(TitleScreen.class) -public class MixinTitleScreen { - - @Inject(at = @At("HEAD"), method = "init()V") - private void init(CallbackInfo info) { - - Constants.LOG.info("This line is printed by an example mod mixin from Forge!"); - Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType()); - } -} \ No newline at end of file diff --git a/forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java b/forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java deleted file mode 100644 index 22ef9e4..0000000 --- a/forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.example.examplemod.platform; - -import com.example.examplemod.platform.services.IPlatformHelper; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLLoader; - -public class ForgePlatformHelper implements IPlatformHelper { - - @Override - public String getPlatformName() { - - return "Forge"; - } - - @Override - public boolean isModLoaded(String modId) { - - return ModList.get().isLoaded(modId); - } - - @Override - public boolean isDevelopmentEnvironment() { - - return !FMLLoader.isProduction(); - } -} \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index e2c1d00..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,26 +0,0 @@ -modLoader = "javafml" #mandatory -loaderVersion = "${forge_loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions. -license = "${license}" # Review your options at https://choosealicense.com/. -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional -[[mods]] #mandatory -modId = "${mod_id}" #mandatory -version = "${version}" #mandatory -displayName = "${mod_name}" #mandatory -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/) -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI) -logoFile = "${mod_id}.png" #optional -credits = "${credits}" #optional -authors = "${mod_author}" #optional -description = '''${description}''' #mandatory (Supports multiline text) -[[dependencies.${mod_id}]] #optional -modId = "forge" #mandatory -mandatory = true #mandatory -versionRange = "${forge_version_range}" #mandatory -ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory -side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER' -[[dependencies.${mod_id}]] -modId = "minecraft" -mandatory = true -versionRange = "${minecraft_version_range}" -ordering = "NONE" -side = "BOTH" diff --git a/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper b/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper deleted file mode 100644 index ff2910d..0000000 --- a/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper +++ /dev/null @@ -1 +0,0 @@ -com.example.examplemod.platform.ForgePlatformHelper \ No newline at end of file diff --git a/forge/src/main/resources/examplemod.forge.mixins.json b/forge/src/main/resources/examplemod.forge.mixins.json deleted file mode 100644 index a8c3e35..0000000 --- a/forge/src/main/resources/examplemod.forge.mixins.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "com.example.examplemod.mixin", - "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", - "mixins": [], - "client": [ - "MixinTitleScreen" - ], - "server": [], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c7c45ee..c481b1d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,29 +4,24 @@ # Project version=1.0.0 group=com.example.examplemod -java_version=17 +java_version=21 # Common -minecraft_version=1.20.4 +minecraft_version=1.20.5 mod_name=ExampleMod mod_author=Jared mod_id=examplemod license=C0-1.0 credits= description=The description of your mod. \nAccepts multilines. -minecraft_version_range=[1.20.4, 1.21) +minecraft_version_range=[1.20.5, 1.21) # Fabric -fabric_version=0.92.1+1.20.4 -fabric_loader_version=0.15.3 - -# Forge -forge_version=49.0.19 -forge_loader_version_range=[49,) -forge_version_range=[49,) +fabric_version=0.97.6+1.20.5 +fabric_loader_version=0.15.10 # NeoForge -neoforge_version=20.4.83-beta +neoforge_version=20.5.0-beta neoforge_loader_version_range=[2,) # Gradle diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 100% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml diff --git a/neoforge/src/main/resources/examplemod.neoforge.mixins.json b/neoforge/src/main/resources/examplemod.neoforge.mixins.json index 523cdf6..1ac6c9b 100644 --- a/neoforge/src/main/resources/examplemod.neoforge.mixins.json +++ b/neoforge/src/main/resources/examplemod.neoforge.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "com.example.examplemod.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "MixinTitleScreen" diff --git a/settings.gradle b/settings.gradle index 1eb13e3..774b87b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,17 +26,6 @@ pluginManagement { includeGroup("codechicken") } } - exclusiveContent { - forRepository { - maven { - name = 'Forge' - url = uri("https://maven.minecraftforge.net") - } - } - filter { - includeGroupAndSubgroups("net.minecraftforge") - } - } exclusiveContent { forRepository { maven { @@ -46,6 +35,7 @@ pluginManagement { } filter { includeGroupAndSubgroups("org.spongepowered") + includeGroup("net.minecraftforge") } } } @@ -59,5 +49,4 @@ plugins { rootProject.name = 'MultiLoader-Template' include("common") include("fabric") -include("forge") include("neoforge")