Class Confabricate
- All Implemented Interfaces:
net.fabricmc.api.ModInitializer
This class has static utility methods for usage by other mods -- it should not be instantiated by anyone but the mod loader.
- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigurationOptionsGet configuration options configured to use Confabricate's serializers.static PathconfigurationFile(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) Get the path to a configuration file in HOCON format formod.configurationFor(net.fabricmc.loader.api.ModContainer mod) Create a configuration reference to the provided mod's main configuration file.configurationFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) Get a configuration reference for a mod.configurationFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory, ConfigurationOptions options) Get a configuration reference for a mod.static TransformActioncreateTransformAction(com.mojang.datafixers.DataFixer fixer, com.mojang.datafixers.DSL.TypeReference reference, int targetVersion, Object... versionKey) Create a TransformAction applying aDataFixerto a Configurate node.static ConfigurationTransformationcreateTransformation(com.mojang.datafixers.DataFixer fixer, com.mojang.datafixers.DSL.TypeReference reference, int targetVersion, Object... versionKey) Create aConfigurationTransformationthat applies aDataFixerto a Configurate node.static WatchServiceListenerAccess the shared watch service for listening to files in this game on the default filesystem.static net.minecraft.resources.ResourceLocationInternal API to get a modResourceLocation.loaderFor(net.fabricmc.loader.api.ModContainer mod) Create a configuration loader for the given mod's main configuration file.loaderFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) Get a configuration loader for a mod.loaderFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory, ConfigurationOptions options) Get a configuration loader for a mod.Return a builder pre-configured to apply Minecraft's DataFixers to the latest game save version.void
-
Constructor Details
-
Confabricate
public Confabricate()
-
-
Method Details
-
id
Internal API to get a modResourceLocation.- Parameters:
item- path value- Returns:
- new identifier
- Since:
- 2.0.0
-
onInitialize
- Specified by:
onInitializein interfacenet.fabricmc.api.ModInitializer
-
confabricateOptions
Get configuration options configured to use Confabricate's serializers.- Returns:
- customized options
- Since:
- 2.0.0
-
loaderFor
public static ConfigurationLoader<CommentedConfigurationNode> loaderFor(net.fabricmc.loader.api.ModContainer mod) Create a configuration loader for the given mod's main configuration file.By default, this config file is in a dedicated directory for the mod.
- Parameters:
mod- the mod wanting to access its config- Returns:
- a configuration loader in the Hocon format
- Since:
- 1.0.0
- See Also:
-
loaderFor
public static ConfigurationLoader<CommentedConfigurationNode> loaderFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) Get a configuration loader for a mod. The configuration will be in Hocon format.If the configuration is in its own directory, the path will be
<config root>/<modid>/<modid>.conf
. Otherwise, the path will be<config root>/<modid>.conf
.The returned
ConfigurationLoaderswill be pre-configured to use the type serializers fromMinecraftSerializers.collection(), but will otherwise use default settings.- Parameters:
mod- the mod to get the configuration loader forownDirectory- whether the configuration should be in a directory just for the mod, or a file in the config root- Returns:
- the newly created configuration loader
- Since:
- 1.0.0
-
loaderFor
public static ConfigurationLoader<CommentedConfigurationNode> loaderFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory, ConfigurationOptions options) Get a configuration loader for a mod. The configuration will be in Hocon format.If the configuration is in its own directory, the path will be
<config root>/<modid>/<modid>.conf
. Otherwise, the path will be<config root>/<modid>.conf
.The returned
ConfigurationLoaderswill be pre-configured to use the type serializers fromMinecraftSerializers.collection(), but will otherwise use default settings.- Parameters:
mod- the mod to get the configuration loader forownDirectory- whether the configuration should be in a directory just for the mod, or a file in the config rootoptions- the options to use by default when loading- Returns:
- the newly created configuration loader
- Since:
- 2.0.0
-
configurationFor
public static ConfigurationReference<CommentedConfigurationNode> configurationFor(net.fabricmc.loader.api.ModContainer mod) throws ConfigurateException Create a configuration reference to the provided mod's main configuration file.By default, this config file is in a dedicated directory for the mod. The returned reference will automatically reload.
- Parameters:
mod- the mod wanting to access its config- Returns:
- a configuration reference for a loaded node in HOCON format
- Throws:
ConfigurateException- if a listener could not be established or if the configuration failed to load.- Since:
- 1.1.0
- See Also:
-
configurationFor
public static ConfigurationReference<CommentedConfigurationNode> configurationFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) throws ConfigurateException Get a configuration reference for a mod. The configuration will be in Hocon format.If the configuration is in its own directory, the path will be
<config root>/<modid>/<modid>.conf
Otherwise, the path will be<config root>/<modid>.conf
.The reference's
ConfigurationLoaderwill be pre-configured to use the type serializers fromMinecraftSerializers.collection()but will otherwise use default settings.- Parameters:
mod- the mod to get the configuration loader forownDirectory- whether the configuration should be in a directory just for the mod- Returns:
- the newly created and loaded configuration reference
- Throws:
ConfigurateException- if a listener could not be established or the configuration failed to load.- Since:
- 1.1.0
-
configurationFor
public static ConfigurationReference<CommentedConfigurationNode> configurationFor(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory, ConfigurationOptions options) throws ConfigurateException Get a configuration reference for a mod. The configuration will be in Hocon format.If the configuration is in its own directory, the path will be
<config root>/<modid>/<modid>.conf
Otherwise, the path will be<config root>/<modid>.conf
.The reference's
ConfigurationLoaderwill be pre-configured to use the type serializers fromMinecraftSerializers.collection()but will otherwise use default settings.- Parameters:
mod- the mod to get the configuration loader forownDirectory- whether the configuration should be in a directory just for the modoptions- the options to use by default when loading- Returns:
- the newly created and loaded configuration reference
- Throws:
ConfigurateException- if a listener could not be established or the configuration failed to load.- Since:
- 2.0.0
-
configurationFile
public static Path configurationFile(net.fabricmc.loader.api.ModContainer mod, boolean ownDirectory) Get the path to a configuration file in HOCON format formod.HOCON uses the
.conffile extension.- Parameters:
mod- container of the modownDirectory- whether the configuration should be in its own directory, or in the main configuration directory- Returns:
- path to a configuration file
- Since:
- 1.1.0
-
createTransformation
public static ConfigurationTransformation createTransformation(com.mojang.datafixers.DataFixer fixer, com.mojang.datafixers.DSL.TypeReference reference, int targetVersion, Object... versionKey) Create aConfigurationTransformationthat applies aDataFixerto a Configurate node. The current version of the node is provided by the pathversionKey. The transformation is executed from the provided node.- Parameters:
fixer- the fixer containing DFU transformations to applyreference- the reference to the DFUDSLtype representing this nodetargetVersion- the version to convert toversionKey- the location of the data version in nodes provided to the transformer- Returns:
- a transformation that executes a
data fixer. - Since:
- 1.1.0
-
createTransformAction
public static TransformAction createTransformAction(com.mojang.datafixers.DataFixer fixer, com.mojang.datafixers.DSL.TypeReference reference, int targetVersion, Object... versionKey) Create a TransformAction applying aDataFixerto a Configurate node. This can be used withinConfigurationTransformationwhen some values are controlled by DFUs and some aren't.- Parameters:
fixer- the fixer containing DFU transformations to applyreference- the reference to the DFUDSLtype representing this nodetargetVersion- the version to convert toversionKey- the location of the data version in nodes seen by this action.- Returns:
- the created action
- Since:
- 1.1.0
-
fileWatcher
Access the shared watch service for listening to files in this game on the default filesystem.- Returns:
- watcher
- Since:
- 1.1.0
-
minecraftDfuBuilder
Return a builder pre-configured to apply Minecraft's DataFixers to the latest game save version.- Returns:
- new transformation builder
- Since:
- 2.0.0
-