Quilt Loader 1
Loading...
Searching...
No Matches
org.quiltmc.loader.api.QuiltLoader Class Reference

The public-facing QuiltLoader instance. More...

Static Public Member Functions

static< T > List< T > getEntrypoints (String key, Class< T > type) throws EntrypointException
 Returns all entrypoints declared under a key, assuming they are of a specific type.
static< T > List< EntrypointContainer< T > > getEntrypointContainers (String key, Class< T > type) throws EntrypointException
 Returns all entrypoints declared under a key, assuming they are of a specific type.
static MappingResolver getMappingResolver ()
 Get the current mapping resolver.
static Optional< ModContainergetModContainer (String id)
 Gets the container for a given mod.
static Collection< ModContainergetAllMods ()
 Gets all mod containers.
static boolean isModLoaded (String id)
 Checks if a mod with a given ID is loaded.
static Optional< ModContainergetModContainer (Class<?> clazz)
 Gets the mod container that provides the given class.
static boolean isDevelopmentEnvironment ()
 Checks if Fabric Loader is currently running in a "development" environment.
static Object getGameInstance ()
 Get the current game instance.
static String getNormalizedGameVersion ()
 Gets the game version, normalised to be usefully compared via Version#compareTo(Version) to other versions of the same game.
static String getRawGameVersion ()
 Gets the game version, unnormalised.
static Path getGameDir ()
 Get the current game working directory.
static Path getCacheDir ()
 Get the current directory for temporary files.
static Path getConfigDir ()
 Get the current directory for game configuration files.
static Path getGlobalCacheDir ()
 Get the global (per-user) directory for cached files.
static Path getGlobalConfigDir ()
 Get the global (per-user) directory for configuration files.
static boolean globalDirsEnabled ()
static String[] getLaunchArguments (boolean sanitize)
 Gets the command line arguments used to launch the game.
static ObjectShare getObjectShare ()
 Get the object share for inter-mod communication.
static String createModTable ()
 Creates a table describing the mods currently loaded, suitable for printing in log files or in crash reports.

Detailed Description

The public-facing QuiltLoader instance.

Member Function Documentation

◆ createModTable()

String org.quiltmc.loader.api.QuiltLoader.createModTable ( )
inlinestatic

Creates a table describing the mods currently loaded, suitable for printing in log files or in crash reports.

All of the information contained here is available through getAllMods().

◆ getAllMods()

Collection< ModContainer > org.quiltmc.loader.api.QuiltLoader.getAllMods ( )
inlinestatic

Gets all mod containers.

Returns
a collection of all loaded mod containers

◆ getCacheDir()

Path org.quiltmc.loader.api.QuiltLoader.getCacheDir ( )
inlinestatic

Get the current directory for temporary files.

Returns
the cache directory

◆ getConfigDir()

Path org.quiltmc.loader.api.QuiltLoader.getConfigDir ( )
inlinestatic

Get the current directory for game configuration files.

Returns
the configuration directory

◆ getEntrypointContainers()

static< T > List< EntrypointContainer< T > > org.quiltmc.loader.api.QuiltLoader.getEntrypointContainers ( String key,
Class< T > type ) throws EntrypointException
inlinestatic

Returns all entrypoints declared under a key, assuming they are of a specific type.

The entrypoint is declared in the fabric.mod.json as following:

"entrypoints": { "&lt;a key&gt;": [ <a list of entrypoint declarations> ] }

Multiple keys can be present in the entrypoints section.

An entrypoint declaration indicates that an arbitrary notation is sent to a LanguageAdapter to offer an instance of entrypoint. It is either a string, or an object. An object declaration is of this form:

{ "adapter": "&lt;a custom adatper&gt;" "value": "&lt;an arbitrary notation&gt;" }

A string declaration <an arbitrary notation> is equivalent to

{ "adapter": "default" "value": "&lt;an arbitrary notation&gt;" }

where the default adapter is the adapter offered by Fabric Loader.

Parameters
keythe key in entrypoint declaration in fabric.mod.json
typethe type of entrypoints
<T>the type of entrypoints
Returns
the entrypoint containers related to this key
Exceptions
EntrypointExceptionif a problem arises during entrypoint creation
See also
LanguageAdapter

◆ getEntrypoints()

static< T > List< T > org.quiltmc.loader.api.QuiltLoader.getEntrypoints ( String key,
Class< T > type ) throws EntrypointException
inlinestatic

Returns all entrypoints declared under a key, assuming they are of a specific type.

Parameters
keythe key in entrypoint declaration in fabric.mod.json
typethe type of entrypoints
<T>the type of entrypoints
Returns
the obtained entrypoints
Exceptions
EntrypointExceptionif a problem arises during entrypoint creation
See also
#getEntrypointContainers(String, Class)

◆ getGameDir()

Path org.quiltmc.loader.api.QuiltLoader.getGameDir ( )
inlinestatic

Get the current game working directory.

Returns
the working directory

◆ getGameInstance()

Object org.quiltmc.loader.api.QuiltLoader.getGameInstance ( )
inlinestatic

Get the current game instance.

Can represent a game client or server object. As such, the exact return is dependent on the current environment type.

The game instance may not always be available depending on the game version and environment.

Returns
A client or server instance object
Deprecated
This method is experimental and it's use is discouraged.

◆ getLaunchArguments()

String[] org.quiltmc.loader.api.QuiltLoader.getLaunchArguments ( boolean sanitize)
inlinestatic

Gets the command line arguments used to launch the game.

If this is printed for debugging, make sure sanitize is true.

Parameters
sanitizeWhether to remove sensitive information
Returns
the launch arguments

◆ getMappingResolver()

MappingResolver org.quiltmc.loader.api.QuiltLoader.getMappingResolver ( )
inlinestatic

Get the current mapping resolver.

When performing reflection, a mod should always query the mapping resolver for the remapped names of members than relying on other heuristics.

Returns
the current mapping resolver instance
Since
0.4.1

◆ getModContainer() [1/2]

Optional< ModContainer > org.quiltmc.loader.api.QuiltLoader.getModContainer ( Class<?> clazz)
inlinestatic

Gets the mod container that provides the given class.

This only works for classes loaded by the system classloader and quilt-loader itself.

◆ getModContainer() [2/2]

Optional< ModContainer > org.quiltmc.loader.api.QuiltLoader.getModContainer ( String id)
inlinestatic

Gets the container for a given mod.

Parameters
idthe ID of the mod
Returns
the mod container, if present

◆ getNormalizedGameVersion()

String org.quiltmc.loader.api.QuiltLoader.getNormalizedGameVersion ( )
inlinestatic

Gets the game version, normalised to be usefully compared via Version#compareTo(Version) to other versions of the same game.

Returns
A normalised version.
See also
getRawGameVersion()

◆ getObjectShare()

ObjectShare org.quiltmc.loader.api.QuiltLoader.getObjectShare ( )
inlinestatic

Get the object share for inter-mod communication.

The share allows mods to exchange data without directly referencing each other. This makes simple interaction easier by eliminating any compile- or run-time dependencies if the shared value type is independent of the mod (only Java/game/Fabric types like collections, primitives, String, Consumer, Function, ...).

Active interaction is possible as well since the shared values can be arbitrary Java objects. For example exposing a Runnable or Function allows the "API" user to directly invoke some program logic.

It is required to prefix the share key with the mod id like mymod:someProperty. Mods should not modify entries by other mods. The share is thread safe.

Returns
the global object share instance

◆ getRawGameVersion()

String org.quiltmc.loader.api.QuiltLoader.getRawGameVersion ( )
inlinestatic

Gets the game version, unnormalised.

This generally won't be usefully comparable to other versions of the same game.

Returns
A string. This wont be empty or null.
See also
getNormalizedGameVersion()

◆ globalDirsEnabled()

boolean org.quiltmc.loader.api.QuiltLoader.globalDirsEnabled ( )
inlinestatic
Returns
true if the global config and cache dirs are actually global, or false if they are simply subfolders of the per-instance folders.

◆ isDevelopmentEnvironment()

boolean org.quiltmc.loader.api.QuiltLoader.isDevelopmentEnvironment ( )
inlinestatic

Checks if Fabric Loader is currently running in a "development" environment.

Can be used for enabling debug mode or additional checks.

This should not be used to make assumptions on certain features, such as mappings, but as a toggle for certain functionalities.

Returns
whether or not Loader is currently in a "development" environment

◆ isModLoaded()

boolean org.quiltmc.loader.api.QuiltLoader.isModLoaded ( String id)
inlinestatic

Checks if a mod with a given ID is loaded.

Parameters
idthe ID of the mod, as defined in fabric.mod.json
Returns
whether or not the mod is present in this Fabric Loader instance

The documentation for this class was generated from the following file:
  • src/main/java/org/quiltmc/loader/api/QuiltLoader.java