Interface Config


public interface Config
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the directory of this config, assuming the base directory is the instance config directory.
    default String
    Returns the file extension of this config.
    default @Nullable String
    Returns the modid associated with this configuration class.
    Returns the name of this config, which is used for the name of the config file saved to disk, and syncing.
    default boolean
     
    default void
    Writes this configuration file instance to disk.
    default net.minecraft.nbt.NbtCompound
     
  • Method Details

    • save

      default void save()
      Writes this configuration file instance to disk. Useful for saving modified values during runtime.
    • writeSyncingTag

      default net.minecraft.nbt.NbtCompound writeSyncingTag()
    • hasAnySyncable

      default boolean hasAnySyncable()
      Returns:
      true if this Config has any values that should be synced to the client
    • getName

      String getName()
      Returns the name of this config, which is used for the name of the config file saved to disk, and syncing.

      The name returned by this method should generally follow Identifier conventions, but this is not enforced:

      • Lowercase
      • No special characters ($, %, ^, etc.)
      • No spaces
      Returns:
      the name of this config, which is used for the name of the config file saved to disk.
    • getModid

      @Nullable default @Nullable String getModid()
      Returns the modid associated with this configuration class.

      This functionality is used for libraries like ModMenu, which depend on modids for configuration screen instances in their menu. If you are intending for this config to have a ModMenu config screen, this method should return the modid specified in your fabric.mod.json.

      If this method is not overridden, null will be returned, which means this config is not explicitly associated with any particular mod.

      Returns:
      the modid of the mod associated with this config, or null if none was specified
    • getExtension

      default String getExtension()
      Returns the file extension of this config.

      The file extension is used while serializing this config to a local file. The primary use-case of switching this would be supporting existing config files when porting from other json5 config libraries.

      Returns:
      the file extension of this config
    • getDirectory

      default String getDirectory()
      Returns the directory of this config, assuming the base directory is the instance config directory.

      By default, a config such as 'my_config' will appear at /config/my_config.json. If this method specifies a directory, such as 'configurations', the config file will appear at /config/configurations/my_config.json.

      Nested directories can be specified by using a string such as 'configurations/client'.

      Returns:
      the directory of this config