HelloWorldFabric patched for the latest Fabric version
.vscode | ||
app | ||
exampleMod | ||
gradle/wrapper | ||
modLoader | ||
run | ||
.gitattributes | ||
.gitignore | ||
gradlew | ||
gradlew.bat | ||
README.md | ||
settings.gradle |
HelloWorldFabric
This is a basic Java application which utilizes the Fabric mod loader to load and apply a Mixin. That sentence sounds like I'm talking about Minecraft, but this is actually an application in pure Java, and you could load any Java application through this.
This project contains three subprojects:
app
: A Hello World application.modLoader
: A Fabric mod loader built to act as a class loader for the Hello World application.exampleMod
: A Fabric mod for the Hello World application, which has a mixin.
How to Test
- Perform
gradle buildAndCopy
onapp/
. This will puthelloworld.jar
, the JAR we plan to inject into, into./run
. - Perform
gradle buildAndCopy
onmodLoader/
. This will putmodloader.jar
, the JAR which overrides class loading for HelloWorld, into./run
. - Perform
gradle buildAndCopy
onexampleMod/
. This will putexamplemod.jar
, the JAR containing a mod with Mixin that affects HelloWorld, into./run/mods
. - Run
./launch.bat
.
What happens here is:
- Fabric Loader is launched via the script
- Fabric Loader detects our ModLoader on the class path, and executes its GameProvider to receive the class path to modify and the game folder to load mods from.
- Fabric Loader loads any applicable mods, in this case our ExampleMod, and initializes it and applies its tranformers.
- At this point, the behavior of
Main.class
in the HelloWorld app is overridden by the Mixin.
- At this point, the behavior of
- Fabric Loader then executes the classpath of the applicattion.
- This invokes
Launch.class
, which in turn invokesMain.class
.
- This invokes
Without the mod installed, "Hello World" is printed, but with it installed, "Goodbye World" is printed.