Skip to content

Instantly share code, notes, and snippets.

@Arc-blroth
Created December 9, 2020 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arc-blroth/b3852f38b366a8bfa55e52ce6a56c3c2 to your computer and use it in GitHub Desktop.
Save Arc-blroth/b3852f38b366a8bfa55e52ce6a56c3c2 to your computer and use it in GitHub Desktop.
Fabric Game Providers
String getGameId();
String getGameName();

These first few methods are just the internal game id (examples: "minecraft", "javac") and user-friendly name of that game (example" "Minecraft")

String getRawGameVersion();
String getNormalizedGameVersion();

The "raw" game version can technically be any string. The "normalized" game version, however, should generally be a proper semantic version. I recommend that it be consistent even if the target game has changed versioning schemes. For example, Java's versioning scheme changed after java 8, from using 1.x to x.x. In JavacGameProvider, I normalize all versions to a 1.x style.

Collection<BuiltinMod> getBuiltinMods();

A list of "builtin" mods. A Builtin mod consists of that mods' id and a url to load that mod from. Generally, you'll provide the id of your game here, along with the path ot the game jar.

String getEntrypoint();

Class name of the entrypoint class (example: "com.mojang.minecraft.server.Main"). Fabric doesn't actually use this, its intended to help mods find the entrypoint no matter the EnvType.

Path getLaunchDirectory();

Directory where the mods/ and config/ folders will be created in and read from.

boolean isObfuscated();

True if the game jar needs deobfuscation.

boolean requiresUrlClassLoader();

If this is true, then Knot will use the KnotCompatibilityClassLoader rather than KnotClassLoader. The main difference between the two is that KnotCompatibilityClassLoader extends from URLClassLoader while KnotClassLoader does not. This might be useful if your target game expects to be loaded on a URLClassLoader (like it would be without fabric).

List<Path> getGameContextJars();

List of other jars that Fabric will run through deobfuscation and add to the classpath.

boolean locateGame(EnvType envType, ClassLoader loader);

Fabric will call this to allow you to find the game jars and entrypoints. Return true if found and false if not.

void acceptArguments(String... arguments);

Fabric will call this with the args from the main method.

EntrypointTransformer getEntrypointTransformer();

MUST NOT be null, even if you don't do any entrypoint transforming. An entrypoint transformer handles raw asm transformation of certain game classes to inject entrypoints.

void launch(ClassLoader loader);

Fabric calls this method once mods are loaded and its ready to launch. Most likely, you'll load the entrypoint class on the provided classloader and then call its main method.

String[] getLaunchArguments(boolean sanitize);

Mods expect this to return the args you were passed in acceptArguments. If sanitize is true, you're expected to remove things like auth tokens from the args before returning it.

default boolean canOpenErrorGui()

Whether or not failing mod loading will open a GUI. If you're modding something in a headless enviornment, say a server, then this should be false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment