Class Confabricate

java.lang.Object
ca.stellardrift.confabricate.Confabricate
All Implemented Interfaces:
net.fabricmc.api.ModInitializer

public class Confabricate extends Object implements net.fabricmc.api.ModInitializer
Configurate integration holder, providing access to configuration loaders pre-configured to work with Minecraft types.

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 Details

  • Method Details

    • id

      public static net.minecraft.resources.ResourceLocation id(String item)
      Internal API to get a mod ResourceLocation.
      Parameters:
      item - path value
      Returns:
      new identifier
      Since:
      2.0.0
    • onInitialize

      public void onInitialize()
      Specified by:
      onInitialize in interface net.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 ConfigurationLoaders will be pre-configured to use the type serializers from MinecraftSerializers.collection(), but will otherwise use default settings.

      Parameters:
      mod - the mod to get the configuration loader for
      ownDirectory - 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 ConfigurationLoaders will be pre-configured to use the type serializers from MinecraftSerializers.collection(), but will otherwise use default settings.

      Parameters:
      mod - the mod to get the configuration loader for
      ownDirectory - whether the configuration should be in a directory just for the mod, or a file in the config root
      options - 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 ConfigurationLoader will be pre-configured to use the type serializers from MinecraftSerializers.collection() but will otherwise use default settings.

      Parameters:
      mod - the mod to get the configuration loader for
      ownDirectory - 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 ConfigurationLoader will be pre-configured to use the type serializers from MinecraftSerializers.collection() but will otherwise use default settings.

      Parameters:
      mod - the mod to get the configuration loader for
      ownDirectory - whether the configuration should be in a directory just for the mod
      options - 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 for mod.

      HOCON uses the .conf file extension.

      Parameters:
      mod - container of the mod
      ownDirectory - 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 a ConfigurationTransformation that applies a DataFixer to a Configurate node. The current version of the node is provided by the path versionKey. The transformation is executed from the provided node.
      Parameters:
      fixer - the fixer containing DFU transformations to apply
      reference - the reference to the DFU DSL type representing this node
      targetVersion - the version to convert to
      versionKey - 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 a DataFixer to a Configurate node. This can be used within ConfigurationTransformation when some values are controlled by DFUs and some aren't.
      Parameters:
      fixer - the fixer containing DFU transformations to apply
      reference - the reference to the DFU DSL type representing this node
      targetVersion - the version to convert to
      versionKey - 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