Interface LayerTemplateValue<T>

Type Parameters:
T - The type this value must become
All Known Implementing Classes:
LayerTemplateValue.FormattedValue, LayerTemplateValue.RawValue

public sealed interface LayerTemplateValue<T> permits LayerTemplateValue.RawValue<T>, LayerTemplateValue.FormattedValue<T>
Helper for managing codecs with string template values.
  • Field Details

    • STRING_CODEC

      static final com.mojang.serialization.Codec<LayerTemplateValue<String>> STRING_CODEC
    • LOCATION_CODEC

      static final com.mojang.serialization.Codec<LayerTemplateValue<net.minecraft.resources.ResourceLocation>> LOCATION_CODEC
  • Method Details

    • rawValue

      String rawValue()
      Returns:
      The raw input from the user
    • parse

      T parse(Object... params) throws IllegalFormatException, net.minecraft.ResourceLocationException
      Attempts to parse the real value of this template.
      Parameters:
      params - The provided parameters for formatting
      Returns:
      The value of this template
      Throws:
      IllegalFormatException - If the formatting string provided is invalid for the parameters
      net.minecraft.ResourceLocationException - If the value is a resource location and is not valid
    • enumCodec

      static <T extends Enum<T>> com.mojang.serialization.Codec<LayerTemplateValue<T>> enumCodec(Class<T> clazz)
      Creates a codec for the specified enum values.
      Type Parameters:
      T - The type of value to store
      Parameters:
      clazz - The enum class to choose values from
      Returns:
      A codec that can use formatting strings to interpret the name of the enum value
    • raw

      static <T extends Enum<T>> LayerTemplateValue.RawValue<T> raw(T value)
      Creates a new raw value for the specified enum value.
      Type Parameters:
      T - The type of enum value to store
      Parameters:
      value - The value to use
      Returns:
      A new raw value, using the name of the enum value as the raw name