Interface ConfigType<T>

Type Parameters:
T - the value's type; values are never null
All Known Implementing Classes:
BooleanType, CodecType, ColorType, EnumType, IdentifierType, ListType, NumberType, StringType

public interface ConfigType<T>
What a config value is: how it's stored (a Codec, so every file format and the network work alike), what it may be, and how it's typed as text in the config screen and commands.

Types are immutable and carry their constraints (ConfigTypes.intRange(int, int)), so a list's elements are checked the same way as a single value. ConfigTypes has the built-in ones; the config screen picks an editor by type, and falls back to a text box using parse(String)/format(T) for types it doesn't know.

  • Method Summary

    Modifier and Type
    Method
    Description
    com.mojang.serialization.Codec<T>
     
    default List<net.minecraft.network.chat.Component>
    The constraints in words, for the file's comments and the screen's tooltips ("Range: 0 ~ 10").
    default boolean
    equals(T first, T second)
     
    default String
    format(T value)
    The value as a player would type it, the inverse of parse(String).
    parse(String text)
    Reads a value typed by a player, and validates it.
    default List<String>
    Values to suggest in commands.
    validate(T value)
    Checks a value, possibly correcting it.
  • Method Details

    • codec

      com.mojang.serialization.Codec<T> codec()
    • validate

      ValidationResult<T> validate(T value)
      Checks a value, possibly correcting it.
    • parse

      default ValidationResult<T> parse(String text)
      Reads a value typed by a player, and validates it. By default the text is JSON for the codec.
    • format

      default String format(T value)
      The value as a player would type it, the inverse of parse(String). By default compact JSON.
    • describe

      default List<net.minecraft.network.chat.Component> describe()
      The constraints in words, for the file's comments and the screen's tooltips ("Range: 0 ~ 10").
    • suggestions

      default List<String> suggestions()
      Values to suggest in commands.
    • equals

      default boolean equals(T first, T second)