A template for a Forge + Fabric project setup using a Common source set.

Overview

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.

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.

  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.
  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 16 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 JVMand changing the value to a valid Java 16 JVM. You will also need to set the Project SDK to Java 16. 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.

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.

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.

Comments
  • Running Forge while building with intellij on `1.18` & `1.18-mixin` branch fails 1.18.1/1.18.2 due to missing `Common` module resources & classes

    Running Forge while building with intellij on `1.18` & `1.18-mixin` branch fails 1.18.1/1.18.2 due to missing `Common` module resources & classes

    This issue also occurs on 1.18.2.

    Here's a video of what happens: https://youtu.be/g-ZUYu0mIWw

    Video starts w/ building w/ gradle, then I switch to Intellij building.

    Fabric building w/ intellij works just fine

    opened by CorgiTaco 10
  • Setting up Yarn mappings?

    Setting up Yarn mappings?

    How would I set up yarn mappings for this? I'd like to stick with the mappings I'm familiar with and also setup some older Fabric projects with this template.

    Fabric's mapping changing is straightforward but I'm stuck on the Forge part as I require a channel and a MC version, is there an alternative to Architectury Loom that I have to use for such a task?

    opened by MerchantPug 7
  • Setup fails on Mac with Loom 0.11-SNAPSHOT

    Setup fails on Mac with Loom 0.11-SNAPSHOT

    When attempting to load/reload the project with IDEA on Mac, setup fails with the following error:

    Could not determine the dependencies of task ':Fabric:configureClientLaunch'.
    > Could not create task ':Fabric:extractNatives'.
       > Could not create task of type 'ExtractNativesTask'.
          > Could not resolve all files for configuration ':Fabric:minecraftNatives'.
             > Could not find java-objc-bridge-1.0.0-natives-osx.jar (ca.weblite:java-objc-bridge:1.0.0).
               Searched in the following locations:
                   https://repo.maven.apache.org/maven2/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0-natives-osx.jar
    
    Possible solution:
     - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
    

    This does not occur with a normal Fabric setup on the same machine. Tested by loading the Fabric Example Mod, which also uses Loom 0.11.

    Workaround: Switch back to Loom 0.10-SNAPSHOT.

    opened by The-Fireplace 7
  • Registry example throws

    Registry example throws "Cannot invoke "net.minecraftforge.fml.ModList.getModContainerById(String)" because the return value of "net.minecraftforge.fml.ModList.get()" is null"

    When running forge client, Cannot invoke "net.minecraftforge.fml.ModList.getModContainerById(String)" because the return value of "net.minecraftforge.fml.ModList.get()" is null is thrown as an error

    opened by mineblock11 3
  • Show an example of calling back into platform specific code

    Show an example of calling back into platform specific code

    In Patchouli and Botania, we use a serviceloader interface called IXplatAbstractions, implemented once by each loader, to allow down calls from Common code back into loader-specific code. This is probably something that is needed often enough that this template should probably have an example of it.

    opened by williewillus 1
  • Maven Publishing

    Maven Publishing

    The current Maven publishing configuration has a few issues and will require some changes to work with a multiproject setup. It looks like you've fixed most of these in your Clumps implementation but I would like to see some of these changes backported here.

    Common Artifacts

    The Common artifacts are not published currently. While normal Forge and Fabric mods can still use MultiLoader projects without the Common artifacts other MultiLoader projects would greatly benefit from having them available. For example imagine writing a CraftTweaker addon in a MultiLoader project. It would make sense for this addon to define new ZenCode natives in the Common project. The same would be true for a GameStage or WAILA addon.

    Inconsistent Artifact Coordinates

    The artifact coordinates for the Forge and Fabric artifacts are not consistent. The version number also differs between version and structure. There would be a lot to gain from standardizing this, especially now that we publish so many artifacts and other MultiLoader projects will be defining them three times. One benefit would be that it becomes easier to share coordinates with others, and make it easier to locate when traversing the maven manually. This will also aid in creating 3rd party tools or helpers to lookup artifacts. For example a helper method that accepts a group, project name, and version and will automatically create dependencies using the template "${group}:${name}-${platform}-${mc_version}:${version}" in the correct subprojects.

    My proposed changes would include the following.

    • Group keeps the same structure. If there were any loader-specific references here they should be removed.
    • Name should be suffixed with the platform name (forge/fabric/common) and include the game version.
    • Version should continue on from the highest major version. So if Forge is 1.0.2 and Fabric is 8.0.12 the next joint release should become 9.0.13 for both.

    Old Artifact Coordinates

    // https://maven.blamejared.com/com/blamejared/clumps/Clumps/6.0.0.27/
    group:'com.blamejared.clumps', name:'Clumps', version:'6.0.0.27'
    
    // https://maven.blamejared.com/com/blamejared/clumps/Clumps-fabric-1.17.1/7.0.8/
    group:'com.blamejared.clumps', name:'Clumps-fabric-1.17.1', version:'7.0.8'
    

    New Artifact Coordinates

    // https://maven.blamejared.com/com/blamejared/clumps/Clumps/6.0.0.27/
    group:'com.blamejared.clumps', name:'Clumps-forge-1.17.1', version:'7.0.9'
    
    // https://maven.blamejared.com/com/blamejared/clumps/Clumps-fabric-1.17.1/7.0.8/
    group:'com.blamejared.clumps', name:'Clumps-fabric-1.17.1', version:'7.0.9'
    

    Misc Improvements

    • Gradle module file is still published but only for forge. Should be disabled for both.
    • Forge's mapped artifact suppression should no longer be needed.
    opened by Darkhax 0
  • Consistency and Bug Fixes

    Consistency and Bug Fixes

    This PR aims to update a few things while also resolving bugs, quirky behavior, and inconsistencies.

    • https://github.com/jaredlll08/MultiLoader-Template/commit/07b5f427402ddd7d5165fbc6efccd71ad6f1b1c7 - Common and Forge had their repositories dictated by the Fabric project. This was likely caused by all sub-projects sharing the same repository set. This was resolved by unifying the repositories block and moving them to the root project build script. I also added your maven here which may be controversial. My reasoning was that this would make things easier for both of us in the future. Your maven is also going to be the only source of Common compatible mods which need further testing and examples in the MDK.
    • https://github.com/jaredlll08/MultiLoader-Template/commit/8550e017a18b0ee054eebd3e8861c23718247c9b - This was previously only applied to Fabric projects as the official Forge MDK has not accounted for this yet. I've moved these options to the root build script to apply them consistently.
    • https://github.com/jaredlll08/MultiLoader-Template/commit/2ddb1a3228284a9662ecfb0a21539eee80f88d19 - This only brings the Mixin classes such as annotations into the Common compilation classpath. It does not add Mixin to the Common runtime or allow Common to define new Mixin configs however this may be a good future addition.
    • https://github.com/jaredlll08/MultiLoader-Template/commit/52f493e141bf52275fdd73a78d70d8285bbd600a This resolves the issue where resources were not included with the Forge or Fabric compiled binaries. This fix is applied the same way Forge includes data generator resources.
    opened by Darkhax 0
  • Added some new things.

    Added some new things.

    • Updated Forge version to the latest at time of PR.
    • Moved Constants.java to the correct package like you asked.
    • Included a README file that explains the steps to set up the template and how to develop for it.
    • Moved all System.out calls to Constants.LOG
    • Cleaned up the example code to be similar on Forge and Fabric. Also added a new tooltip example to show how the template may be used.
    • Made Forge run names similar to the Fabric and Common ones. Forge prepends the Forge part using the project folder structure.
    • Removed the JAR manifest entries as they're already added here.
    opened by Darkhax 0
  • Help using loom in common module

    Help using loom in common module

    Hello, I have attempted changing my common module to use fabric loom, but I get an error when running the game that I can't solve.

    The TLDR of why I want to do this is two reasons. First, the supposed performance improvements. However more importantly, I want to create a new module which my fabric module would depend on that would itself depend on the fabric api. When trying to create this module, I get the same error.

    Attempt

    You can view my attempt here: https://github.com/dodogang/MultiLoader-Template/commit/e4882eaf0fa6415a5af947dc749ebcd3cb53fca0

    However, the only changes are in the Common/build.gradle

    plugins {
    -   id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
    +   id 'fabric-loom' version '0.12-SNAPSHOT'
    }
    
    dependencies {
    +   minecraft "com.mojang:minecraft:${minecraft_version}"
    +   mappings loom.officialMojangMappings()
    +
        compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
        implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
    }
    

    However, this gives the following error when running both Fabric Client and Forge Client

    Circular dependency between the following tasks:
    :Common:prepareRemapJar
    \--- :Fabric:jar
         \--- :Fabric:classes
              \--- :Fabric:compileJava
                   \--- :Common:remapJar
                        \--- :Common:prepareRemapJar (*)
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    

    The full build output is provided here, however it doesn't give much more information than what is above.

    I have exhausted my knowledge of gradle today trying to figure out why this error is occurring. I expect there is a loom flag I don't know about that would solve this. Either way, if you have a lead on what can fix this error I'd love to here it :)

    opened by Trikzon 13
  • Parchment mappings

    Parchment mappings

    Currently, parchment mappings cannot be used on MultiLoader-Template, as the Common project uses vanillagradle, which only supports mojang mappings. This means that when, for instance, navigating code in IntelliJ, code in the Common part will link to the normal, mojmaps-without-parameter-names mappings, even if the Forge or Fabric buildscripts are changed to use parchment. This could be fixed by switching the Common setup to use loom, though I am not sure what other routes might be possible. I do know that there is currently a pull request draft for mapping support open on vanillagradle, but I am not sure what the timeline looks like for that.

    opened by lukebemish 3
  • Implementing test mod

    Implementing test mod

    Hey I'm trying to implement a testmod for each fabric and forge. I tried multiple things now but I run into several problems when I try different things.

    Goal is that fabric test sources have access to common test & main sources. Forge test sources should have access to common test & main. And common test has access to main sources.

    My tries:

    Using testFixtures:

    Instead of common test a testFixtures sourceset exists. From the gradle wiki it tells that testFixtures has access to main but they don't have and I could not figure out why.

    Dependency to sourceSets example:

    adding this to Fabric and Forge gradle: Sources seems to have access to each other. At least I don't have errors in the IDE.

        testImplementation project(":Common").sourceSets.main.output
        testImplementation project(":Common").sourceSets.test.output
    

    ###Runconfig for Fabric: -> Results into fabric just starts without the test mod loaded.

            testClient {
                client()
                source = sourceSets.test
                setConfigName("Test Minecraft Client")
                ideConfigGenerated(true)
                runDir("../run")
            }
    

    Runconfig for Forge:

    --> Crashes because some packages are exported by multiple mods. I assume it's because the mod or the testmod exports the same package? The package names are different. So I don't really understand whats happening here.

            clientTest {
                parent runs.client
                environment 'MOD_CLASSES', 'dummy' // From Forge: FG will replace this but it's needed to run
                mods {
                    modClientRun {
                        source sourceSets.main
                        source project(":Common").sourceSets.main
                    }
                    "${mod_id}_test" {
                        source sourceSets.test
                        source project(":Common").sourceSets.test
                    }
                }
            }
    

    When I look into the build folders the resources are correct and the mods have their mods.toml or fabric.mod.json file.

    I mostly tried to learn from this and the links they added: https://stackoverflow.com/questions/5644011/multi-project-test-dependencies-with-gradle

    And sorry for my english ._.'

    opened by LLytho 5
Owner
Jared
Java. React. NodeJS
Jared
An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or to turn an existing project into a devops project using open source software (Git, Docker, Jenkins..)

DevOpsify Description An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or t

obaydah bouifadene 14 Nov 8, 2022
Section B of Assignment 1. Setup project and collaborate on GitHub by writing test fixtures.

Task Each member (including the team leader) should create a branch (use student number as the branch name) and include a small program in the branch

Quinn Frost 1 Apr 6, 2022
Connection Pool Test Setup

Connection Pool Test Setup Setup to test the behavior of http connection pools with the following setup server-apache apache server with proxy-pass to

Johannes Wendig 1 Jan 21, 2022
Template mod to make an addon mod for Create fabric.

Create Fabric Addon Template This template mod comes pre-configured for developing an addon mod for Create on Fabric. Setup For environment setup inst

null 14 Dec 29, 2022
This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap

This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap. It has an automatic database creation, auto initial load of the data, with different variety of users. It also has a checkstyle to check the proper coding of your project immediately right after you enter the code.

null 90 Oct 21, 2022
This project contains many sample codes for demonstrating the usage of some common design patterns.

STUDY COMMON DESIGN PATTERNS 1. About this project This project contains many sample codes for demonstrating the usage of the following design pattern

Võ Trần Minh Quân 21 Jan 2, 2023
Set of project to test how fast is compilation on your computer

Бенчмарк сборки Android проектов Репозиторий содержит несколько проектов, для которые необходимо запустить тесты и зарепортить их результаты Методика

Android Broadcast 3 Jul 29, 2022
How to configure Replica Set with Embedded Mongo using Spring Boot and Flapdoodle for unit testing code that uses mongodb transactions

Spring Boot Embedded Mongo with Replica Set This project defines a basic rest service that allows users to update records of a Person (name and email)

Divyansh Shekhar Gaur 4 Nov 1, 2022
A Java-based template project for the FastJ Game Engine.

FastJ Java Template Program Requirements Java 16 JDK Basic understanding of Java Initial Setup Download the Template You have a few options for gettin

Andrew Dey 13 May 15, 2022
A boilerplate project designed to work as a template for new microservices and help you get in touch with various useful concepts.

Microservice Reference Project This project is inspired by the idea to quickly create a production ready project with all the required infrastructure

Innovation & Tech 4 Dec 17, 2022
JavaFX or Swing + jpackage + Maven template project for generating native desktop applications.

Java + Maven + GitHub Actions = Native Desktop Apps JavaFX or Swing + jpackage + Maven template project for generating native desktop applications. Go

Will Iverson 243 Dec 24, 2022
A library for common extensions for Truth.

truth-extensions A library for common extensions for Truth. Usage Repository To depend on a release, you need only depend on the official Maven centra

Mardrömmar 2 Jan 24, 2022
Eclipse Temurin™ build scripts - common across all releases/versions

Repository for code and instructions for building OpenJDK binaries, defaulting to Eclipse Temurin™ These scripts can be used to build OpenJDK anywhere

Eclipse Adoptium 914 Jan 4, 2023
The common module is for the TenIO framework.

TenIO Common Module TenIO is an open-source project to create multiplayer online games that includes a java NIO (Non-blocking I/O) based server specif

Kong 1 Nov 24, 2021
Fabric mod to (maybe) ignore global bans while still using the auth server

=== SECURITY WARNING === DO NOT USE THIS MOD IF YOU DO NOT 100% TRUST THE SERVER NOT TO STEAL YOUR ACCOUNT. This mod is not secure because servers wil

null 15 Dec 20, 2022
Spawn in the nether with a set of items. Made by logwet, designed by k4yfour, idea by Fyroah.

Noverworld Noverworld About Creating your own custom inventory Support FAQ About When you create a new world, you will spawn in the nether at a portal

null 13 Nov 24, 2022
A set of example projects utilizing Discord4J

Discord4J Example Projects Provided are a set of very simple example projects showcasing two simple slash commands: ping-pong and greet using Discord4

null 17 Nov 8, 2022
Forge 1.18 Custom Base Client

Phase Forge 1.18 Custom Base Client. Hello! no im not back this is more of a when im bored thing. wanted to code so i decided i would make my own cust

Ace_ 10 Dec 2, 2022
A proper Name Spoofer mod for Minecraft Forge 1.8.9.

Name-Spoofer Change ANY text displayed on your screen visually. *It does not actually change any strings and is client side (If you spoof a 1 characte

Exploration 3 Dec 15, 2022