User Tools

Site Tools


documentation:fabric_loader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
documentation:fabric_loader [2022/12/22 15:03] – Added a section on how to integrate Fabric loader into a separate game/app mchorsedocumentation:fabric_loader [2023/12/27 12:57] (current) – ↷ Links adapted because of a move operation 194.190.81.32
Line 86: Line 86:
     // your dependencies...     // your dependencies...
          
-    implementation "net.fabricmc:fabric-loader:0.13.0", +    implementation "net.fabricmc:fabric-loader:0.13.0" 
-    implementation "net.fabricmc:access-widener:2.1.0", +    implementation "net.fabricmc:access-widener:2.1.0" 
-    implementation "net.fabricmc:tiny-mappings-parser:0.2.2.14", +    implementation "net.fabricmc:tiny-mappings-parser:0.2.2.14" 
-    implementation "com.google.guava:guava:21.0", +    implementation "com.google.guava:guava:21.0" 
-    implementation "com.google.code.gson:gson:2.8.7", +    implementation "com.google.code.gson:gson:2.8.7" 
-    implementation "org.ow2.asm:asm:9.2", +    implementation "org.ow2.asm:asm:9.2" 
-    implementation "org.ow2.asm:asm-analysis:9.2", +    implementation "org.ow2.asm:asm-analysis:9.2" 
-    implementation "org.ow2.asm:asm-commons:9.2", +    implementation "org.ow2.asm:asm-commons:9.2" 
-    implementation "org.ow2.asm:asm-tree:9.2", +    implementation "org.ow2.asm:asm-tree:9.2" 
-    implementation "org.ow2.asm:asm-util:9.2",+    implementation "org.ow2.asm:asm-util:9.2"
 } }
 </code> </code>
Line 101: Line 101:
 ==== Launching your app with Fabric Loader ==== ==== Launching your app with Fabric Loader ====
  
-If you've launched your app before through your own ''main(String[])'', to incorporate Fabric Loader into your app, you will need to set its main class to use one of the Knot launchers. For client-side (or if you don't have client/server), specify ''net.fabricmc.loader.impl.launch.knot.KnotClient'' as your main class. For server-side only, specify ''net.fabricmc.loader.impl.launch.knot.KnotServer''. You might ask, "but how will Fabric Loader know how to load my game?" That's where **GameProvider** comes into play.+If you've launched your app before through your own ''main(String[])'', to incorporate Fabric Loader into your app, you will need to set its main class to use one of the Knot launchers. For client-side (or if you don't have client/server separation), specify ''net.fabricmc.loader.impl.launch.knot.KnotClient'' as your main class. For server-side only, specify ''net.fabricmc.loader.impl.launch.knot.KnotServer''. You might ask, "but how will Fabric Loader know how to load my game?" That's where **GameProvider** comes into play.
  
 ==== Setting up GameProvider ==== ==== Setting up GameProvider ====
Line 115: Line 115:
 === Implementing GameProvider === === Implementing GameProvider ===
  
-For your game actually to launch, you to carefully implement **GameProvider** in a specific way. Here is a breakdown of each method does:+For your game actually to launch, you need to carefully implement **GameProvider** in a specific way. Here is a breakdown of each method does:
  
   * ''getGameId()'' and ''getGameName()'', self-explanatory, app's ID like ''epic_app'', and app's name ''Epic App''.   * ''getGameId()'' and ''getGameName()'', self-explanatory, app's ID like ''epic_app'', and app's name ''Epic App''.
-  * ''getRawGameVersion()'' and ''getNormalizedGameVersion()'', it's not entirely clear, but raw version seem to include git-hash, or any information about the game that developer may want to know (like ''v0.1.2+build17#f73acde''), while normalized version is for display (like ''v0.1.2'').+  * ''getRawGameVersion()'' and ''getNormalizedGameVersion()'', it's not entirely clear, but raw version can include git-hash, or any information about the game that developer may want to know (like ''v0.1.2+build17#f73acde''), while normalized version seems to be for display (like ''v0.1.2'').
   * ''getBuiltinMods()'' allows you to provide built-in mod(s), which can be used by mods to target specific version, but it's completely optional, and you can just return ''Collections.emptyList()''.   * ''getBuiltinMods()'' allows you to provide built-in mod(s), which can be used by mods to target specific version, but it's completely optional, and you can just return ''Collections.emptyList()''.
   * ''getEntryPoint()'', full class name of your main app class. It seems to be used only in Minecraft.   * ''getEntryPoint()'', full class name of your main app class. It seems to be used only in Minecraft.
   * ''getLaunchDirectory()'' is a very important method. It should return where the app's resources folder is (like configs, data, saves, etc.). That's where Fabric Loader will create ''config'' and ''mods'' folder, and from which mods will be loaded from!   * ''getLaunchDirectory()'' is a very important method. It should return where the app's resources folder is (like configs, data, saves, etc.). That's where Fabric Loader will create ''config'' and ''mods'' folder, and from which mods will be loaded from!
   * ''isObfuscated()'' whether your app is obfuscated.   * ''isObfuscated()'' whether your app is obfuscated.
-  * ''requiresUrlClassLoader()'' it forces Fabric Loader to use a different compatibility class loader.+  * ''requiresUrlClassLoader()'' it forces **Fabric Loader** to use a different compatibility class loader.
   * ''isEnabled()'' whether your app is enabled. Just ''return true;''   * ''isEnabled()'' whether your app is enabled. Just ''return true;''
   * ''locateGame(FabricLauncher, String[])'' that's where you need to parse the arguments with ''net.fabricmc.loader.impl.util.Arguments'', locate the game directory and ''return true;'' if game directory was found.   * ''locateGame(FabricLauncher, String[])'' that's where you need to parse the arguments with ''net.fabricmc.loader.impl.util.Arguments'', locate the game directory and ''return true;'' if game directory was found.
Line 130: Line 130:
   * ''unlockClassPath(FabricLauncher)'' is called after transformers (i.e. Mixin) were initialized and mods were detected and loaded (but not initialized).    * ''unlockClassPath(FabricLauncher)'' is called after transformers (i.e. Mixin) were initialized and mods were detected and loaded (but not initialized). 
   * ''launch(ClassLoader)'' this is where you launch your app. **Important**: the app must be launched through reflection using the given **ClassLoader**, about that later.   * ''launch(ClassLoader)'' this is where you launch your app. **Important**: the app must be launched through reflection using the given **ClassLoader**, about that later.
-  * ''getArguments()'' simply return the ''Arguments'' instance in ''locateGame(FabricLauncher, String[]))''.+  * ''getArguments()'' simply return the ''Arguments'' instance you initialized in ''locateGame(FabricLauncher, String[]))''.
   * ''getLaunchArguments(boolean)'' simply ''return this.getArguments.toArray()''.   * ''getLaunchArguments(boolean)'' simply ''return this.getArguments.toArray()''.
    
-For more information either consult the Fabric Loader's source code or ''net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider'' for more examples. An example GameProvider would look like this:+An example **GameProvider** would look like this:
  
 <code java> <code java>
Line 262: Line 262:
 </code> </code>
  
-This class example assumes that argument ''--gameDirectory'' is the one that specifies where app's working directory is located. Adjust if needed.+This class example assumes that argument ''--gameDirectory'' is the one that specifies where app's working directory is located. Adjust if needed. 
  
 ==== Final touches ==== ==== Final touches ====
Line 278: Line 278:
 </code> </code>
  
-That's a good sign. However, that's not it+That's a good sign. However, that's not all
  
 === Initializing mods === === Initializing mods ===
Line 324: Line 324:
 </code> </code>
  
-Then it's the root of the issue. To fix this, you need to add your App's jar, or folder (in development) to ''FabricLauncher'''s class path. This could be done by looking in the class path for your jar/folder, and detecting some key files unique to your app. Here is what you can do:+Then it's the root of the issue. To fix this, you need to add your app's jar, or folder (in development) to ''FabricLauncher'''s class path. This could be done by looking in the class path for your jar/folder, and detecting some key files unique to your app. Here is what you can do:
  
 <code java> <code java>
Line 338: Line 338:
  
         this.jarFiles.add("net/developer/app/App.class");         this.jarFiles.add("net/developer/app/App.class");
-        this.jarFiles.add("net/developer/app/AppRegistries.class");+        this.jarFiles.add("net/developer/app/MainApp.class");
     }     }
          
Line 410: Line 410:
 </code> </code>
  
-After detecting the app's jar(s)/folder(s) and adding them to ''FabricLauncher'''s class path, Mixins should work in both development and release environment. +After detecting the app's jar(s)/folder(s) and adding them to ''FabricLauncher'''s class path, Mixins should work in both development and release environment after that
  
 === Loading mods from classpath === === Loading mods from classpath ===
Line 416: Line 416:
 If you're testing the mod from the submodule that has your app and Fabric Loader in the classpath, instead of compiling the mod and placing it into app's launch directory, for Fabric Loader to load your mod from classpath, you need to add ''-Dfabric.development=true'' to JVM flags when running it, then mod(s) from classpath would be loaded too.  If you're testing the mod from the submodule that has your app and Fabric Loader in the classpath, instead of compiling the mod and placing it into app's launch directory, for Fabric Loader to load your mod from classpath, you need to add ''-Dfabric.development=true'' to JVM flags when running it, then mod(s) from classpath would be loaded too. 
  
-For more reference check out [[https://github.com/FabricMC/fabric-loader|Fabric Loader's]] source and this [[https://github.com/PseudoDistant/ExampleGameProvider|GameProvider example]].+For more reference check out [[https://github.com/FabricMC/fabric-loader|Fabric Loader's]] source, ''net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider'', and this [[https://github.com/PseudoDistant/ExampleGameProvider|GameProvider example]].
documentation/fabric_loader.1671721435.txt.gz · Last modified: 2022/12/22 15:03 by mchorse