Quilt Loader 1
Loading...
Searching...
No Matches
net.fabricmc.loader.api.FabricLoader Interface Reference

The public-facing FabricLoader instance. More...

Inheritance diagram for net.fabricmc.loader.api.FabricLoader:
net.fabricmc.loader.FabricLoader net.fabricmc.loader.impl.FabricLoaderImpl

Public Member Functions

< T > List< T > getEntrypoints (String key, Class< T > type)
 Returns all entrypoints declared under a key, assuming they are of a specific type.
< T > List< EntrypointContainer< T > > getEntrypointContainers (String key, Class< T > type)
 Returns all entrypoints declared under a key, assuming they are of a specific type.
< T > void invokeEntrypoints (String key, Class< T > type, Consumer<? super T > invoker)
 Invokes an action on all entrypoints that would be returned by getEntrypointContainers(String, Class) for the given key and type.
ObjectShare getObjectShare ()
 Get the object share for inter-mod communication.
MappingResolver getMappingResolver ()
 Get the current mapping resolver.
Optional< ModContainergetModContainer (String id)
 Gets the container for a given mod.
Optional< ModContainerquilt_getModContainer (Class<?> clazz)
 Provided to make it easier to call QuiltLoader#getModContainer(Class) via reflection for fabric-only mods.
Collection< ModContainergetAllMods ()
 Gets all mod containers.
boolean isModLoaded (String id)
 Checks if a mod with a given ID is loaded.
boolean isDevelopmentEnvironment ()
 Checks if Fabric Loader is currently running in a "development" environment.
EnvType getEnvironmentType ()
 Get the current environment type.
String getRawGameVersion ()
 Get the original unprocessed game version.
Object getGameInstance ()
 Get the current game instance.
Path getGameDir ()
 Get the current game working directory.
File getGameDirectory ()
Path getConfigDir ()
 Get the current directory for game configuration files.
File getConfigDirectory ()
String[] getLaunchArguments (boolean sanitize)
 Gets the command line arguments used to launch the game.

Static Public Member Functions

static FabricLoader getInstance ()
 Returns the public-facing Fabric Loader instance.

Detailed Description

The public-facing FabricLoader instance.

To obtain a working instance, call getInstance().

Since
0.4.0
Deprecated
Please migrate to using QuiltLoader directly instead - except for getEnvironmentType(), which is now located in MinecraftQuiltLoader.

Member Function Documentation

◆ getAllMods()

Collection< ModContainer > net.fabricmc.loader.api.FabricLoader.getAllMods ( )

Gets all mod containers.

Returns
a collection of all loaded mod containers

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getConfigDir()

Path net.fabricmc.loader.api.FabricLoader.getConfigDir ( )

Get the current directory for game configuration files.

Returns
the configuration directory

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getEntrypointContainers()

< T > List< EntrypointContainer< T > > net.fabricmc.loader.api.FabricLoader.getEntrypointContainers ( String key,
Class< T > type )

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()

< T > List< T > net.fabricmc.loader.api.FabricLoader.getEntrypoints ( String key,
Class< T > type )

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
See also
#getEntrypointContainers(String, Class)

Implemented in net.fabricmc.loader.FabricLoader.

◆ getEnvironmentType()

EnvType net.fabricmc.loader.api.FabricLoader.getEnvironmentType ( )

Get the current environment type.

Returns
the current environment type

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getGameDir()

Path net.fabricmc.loader.api.FabricLoader.getGameDir ( )

Get the current game working directory.

Returns
the working directory

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getGameInstance()

Object net.fabricmc.loader.api.FabricLoader.getGameInstance ( )

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 its use is discouraged.

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getLaunchArguments()

String[] net.fabricmc.loader.api.FabricLoader.getLaunchArguments ( boolean sanitize)

Gets the command line arguments used to launch the game.

The implementation will try to strip or obscure sensitive data like authentication tokens if sanitize is set to true. Callers are highly encouraged to enable sanitization as compromising the information can easily happen with logging, exceptions, serialization or other causes.

There is no guarantee that sanitize covers everything, so the launch arguments should still not be logged or otherwise exposed routinely even if the parameter is set to true. In particular it won't necessarily strip all information that can be used to identify the user.

Parameters
sanitizeWhether to try to remove or obscure sensitive information
Returns
the launch arguments for the game

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getMappingResolver()

MappingResolver net.fabricmc.loader.api.FabricLoader.getMappingResolver ( )

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

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getModContainer()

Optional< ModContainer > net.fabricmc.loader.api.FabricLoader.getModContainer ( String id)

Gets the container for a given mod.

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

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getObjectShare()

ObjectShare net.fabricmc.loader.api.FabricLoader.getObjectShare ( )

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
Since
0.12.0

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ getRawGameVersion()

String net.fabricmc.loader.api.FabricLoader.getRawGameVersion ( )

Get the original unprocessed game version.

There is normally a Semver-compatible derived game version, obtainable from a mod container representing the game, that is derived from this raw version. The raw version may not comparable or even follow a well defined pattern, making it unusable for dependency range evaluation.

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ invokeEntrypoints()

< T > void net.fabricmc.loader.api.FabricLoader.invokeEntrypoints ( String key,
Class< T > type,
Consumer<? super T > invoker )

Invokes an action on all entrypoints that would be returned by getEntrypointContainers(String, Class) for the given key and type.

The action is invoked by applying the given invoker to each entrypoint instance.

Exceptions thrown by invoker will be collected and thrown after all entrypoints have been invoked.

Parameters
keythe key in entrypoint declaration in fabric.mod.json
typethe type of entrypoints
invokerapplied to each entrypoint to invoke the desired action
<T>the type of entrypoints
See also
#getEntrypointContainers(String, Class)

◆ isDevelopmentEnvironment()

boolean net.fabricmc.loader.api.FabricLoader.isDevelopmentEnvironment ( )

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

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ isModLoaded()

boolean net.fabricmc.loader.api.FabricLoader.isModLoaded ( String id)

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

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.

◆ quilt_getModContainer()

Optional< ModContainer > net.fabricmc.loader.api.FabricLoader.quilt_getModContainer ( Class<?> clazz)

Provided to make it easier to call QuiltLoader#getModContainer(Class) via reflection for fabric-only mods.

Implemented in net.fabricmc.loader.impl.FabricLoaderImpl.


The documentation for this interface was generated from the following file:
  • src/fabric/api/java/net/fabricmc/loader/api/FabricLoader.java