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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<LayerTemplateValue<net.minecraft.resources.ResourceLocation>> static final com.mojang.serialization.Codec<LayerTemplateValue<String>> -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Enum<T>>
com.mojang.serialization.Codec<LayerTemplateValue<T>> Creates a codec for the specified enum values.Attempts to parse the real value of this template.static <T extends Enum<T>>
LayerTemplateValue.RawValue<T> raw(T value) Creates a new raw value for the specified enum value.rawValue()
-
Field Details
-
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
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 parametersnet.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
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
-