Class ModConfigSpec.ConfigValue<T>

java.lang.Object
net.neoforged.neoforge.common.ModConfigSpec.ConfigValue<T>
All Implemented Interfaces:
Supplier<T>
Direct Known Subclasses:
ModConfigSpec.BooleanValue, ModConfigSpec.DoubleValue, ModConfigSpec.EnumValue, ModConfigSpec.IntValue, ModConfigSpec.LongValue
Enclosing class:
ModConfigSpec

public static class ModConfigSpec.ConfigValue<T> extends Object implements Supplier<T>
  • Field Details

  • Constructor Details

  • Method Details

    • getPath

      public List<String> getPath()
    • get

      public T get()
      Returns the configured value for the configuration setting, throwing if the config has not yet been loaded.

      This getter is cached, and will respect the world restart and game restart options by not clearing its cache if one of those options are set.

      Specified by:
      get in interface Supplier<T>
      Returns:
      the configured value for the setting
      Throws:
      NullPointerException - if the config spec object that will contain this has not yet been built
      IllegalStateException - if the associated config has not yet been loaded
    • getRaw

      public T getRaw()
      Returns the uncached value for the configuration setting, throwing if the config has not yet been loaded.

      Do not call this for any other purpose than editing the value. Use get() instead.

    • getRaw

      public T getRaw(com.electronwill.nightconfig.core.Config config, List<String> path, Supplier<T> defaultSupplier)
    • getDefault

      public T getDefault()
      Returns the default value for the configuration setting.
      Returns:
      the default value for the configuration setting
    • next

      public ModConfigSpec.Builder next()
    • save

      public void save()
    • set

      public void set(T value)
      Directly sets the value, without firing events or writing the config to disk. Make sure to call ModConfigSpec.save() eventually.
    • getSpec

      public ModConfigSpec.ValueSpec getSpec()
    • clearCache

      public void clearCache()