Package net.fabricmc.loader.api
Interface FabricLoader
public interface FabricLoader
The public-facing FabricLoader instance.
To obtain a working instance, call getInstance()
.
- Since:
- 0.4.0
-
Method Summary
Modifier and Type Method Description Collection<ModContainer>
getAllMods()
Gets all mod containers.Path
getConfigDir()
Get the current directory for game configuration files.File
getConfigDirectory()
Deprecated.<T> List<EntrypointContainer<T>>
getEntrypointContainers(String key, Class<T> type)
Returns all entrypoints declared under akey
, assuming they are of a specific type.<T> List<T>
getEntrypoints(String key, Class<T> type)
Returns all entrypoints declared under akey
, assuming they are of a specific type.EnvType
getEnvironmentType()
Get the current environment type.Path
getGameDir()
Get the current game working directory.File
getGameDirectory()
Deprecated.Object
getGameInstance()
Deprecated.This method is experimental and it's use is discouraged.static FabricLoader
getInstance()
Returns the public-facing Fabric Loader instance.String[]
getLaunchArguments(boolean sanitize)
Gets the command line arguments used to launch the game.MappingResolver
getMappingResolver()
Get the current mapping resolver.Optional<ModContainer>
getModContainer(String id)
Gets the container for a given mod.boolean
isDevelopmentEnvironment()
Checks if Fabric Loader is currently running in a "development" environment.boolean
isModLoaded(String id)
Checks if a mod with a given ID is loaded.
-
Method Details
-
getInstance
Returns the public-facing Fabric Loader instance. -
getEntrypoints
Returns all entrypoints declared under akey
, assuming they are of a specific type.- Type Parameters:
T
- the type of entrypoints- Parameters:
key
- the key in entrypoint declaration infabric.mod.json
type
- the type of entrypoints- Returns:
- the obtained entrypoints
- See Also:
getEntrypointContainers(String, Class)
-
getEntrypointContainers
Returns all entrypoints declared under akey
, assuming they are of a specific type.The entrypoint is declared in the
fabric.mod.json
as following:
Multiple keys can be present in the"entrypoints": { "<a key>": [ <a list of entrypoint declarations> ] }
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:
A string declaration{ "adapter": "<a custom adatper>" "value": "<an arbitrary notation>" }
<an arbitrary notation>
is equivalent to
where the{ "adapter": "default" "value": "<an arbitrary notation>" }
default
adapter is the adapter offered by Fabric Loader.- Type Parameters:
T
- the type of entrypoints- Parameters:
key
- the key in entrypoint declaration infabric.mod.json
type
- the type of entrypoints- Returns:
- the entrypoint containers related to this key
- Throws:
EntrypointException
- if a problem arises during entrypoint creation- See Also:
LanguageAdapter
-
getMappingResolver
MappingResolver 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
-
getModContainer
Gets the container for a given mod.- Parameters:
id
- the ID of the mod- Returns:
- the mod container, if present
-
getAllMods
Collection<ModContainer> getAllMods()Gets all mod containers.- Returns:
- a collection of all loaded mod containers
-
isModLoaded
Checks if a mod with a given ID is loaded.- Parameters:
id
- the ID of the mod, as defined infabric.mod.json
- Returns:
- whether or not the mod is present in this Fabric Loader instance
-
isDevelopmentEnvironment
boolean 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
-
getEnvironmentType
EnvType getEnvironmentType()Get the current environment type.- Returns:
- the current environment type
-
getGameInstance
Deprecated.This method is experimental and it's use is discouraged.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
-
getGameDir
Path getGameDir()Get the current game working directory.- Returns:
- the working directory
-
getGameDirectory
Deprecated. -
getConfigDir
Path getConfigDir()Get the current directory for game configuration files.- Returns:
- the configuration directory
-
getConfigDirectory
Deprecated. -
getLaunchArguments
Gets the command line arguments used to launch the game. If this is printed for debugging, make suresanitize
istrue
.- Parameters:
sanitize
- Whether to remove sensitive information- Returns:
- the launch arguments
-