Package net.minestom.server.codec
Interface Codec<T>
- Type Parameters:
T- The type to be represented by this codec
- All Known Subinterfaces:
DataComponent<T>,StructCodec<R>
A Codec represents a combined Encoder and Decoder for a value.
Heavily inspired by Mojang/DataFixerUpper, licensed under the MIT license.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull Codec<byte[]> static final @NotNull Codec<int[]> static final @NotNull Codec<net.kyori.adventure.key.Key> static final @NotNull Codec<long[]> static final @NotNull Codec<net.kyori.adventure.nbt.BinaryTag> static final @NotNull Codec<net.kyori.adventure.nbt.CompoundBinaryTag> static final @NotNull Codec<Codec.RawValue> -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull Codec<T> ForwardRef(@NotNull Supplier<Codec<T>> func) list()list(int maxSize) listOrSingle(int maxSize) optional()static <T> @NotNull Codec<T> static <T> @NotNull StructCodec<T> RegistryTaggedUnion(@NotNull Registry<StructCodec<? extends T>> registry, @NotNull Function<T, StructCodec<? extends T>> serializerGetter, @NotNull String key) static <T> @NotNull StructCodec<T> RegistryTaggedUnion(Registries.Selector<StructCodec<? extends T>> registrySelector, @NotNull Function<T, StructCodec<? extends T>> serializerGetter, @NotNull String key) set()set(int maxSize) default <S> @NotNull Codec<S> transform(@NotNull ThrowingFunction<T, S> to, @NotNull ThrowingFunction<S, T> from) default <R,T1 extends T, TR extends R>
StructCodec<R> unionType(@NotNull String keyField, @NotNull Function<T, StructCodec<TR>> serializers, @NotNull Function<R, T1> keyFunc) default <R,T1 extends T, TR extends R>
StructCodec<R> unionType(@NotNull Function<T, StructCodec<TR>> serializers, @NotNull Function<R, T1> keyFunc)
-
Field Details
-
RAW_VALUE
-
UNIT
-
BOOLEAN
-
BYTE
-
SHORT
-
INT
-
LONG
-
FLOAT
-
DOUBLE
-
STRING
-
KEY
-
BYTE_ARRAY
-
INT_ARRAY
-
LONG_ARRAY
-
UUID
-
UUID_COERCED
-
COMPONENT
-
COMPONENT_STYLE
-
BLOCK_POSITION
-
VECTOR3D
-
NBT
-
NBT_COMPOUND
-
-
Method Details
-
Enum
-
Recursive
-
ForwardRef
-
RegistryTaggedUnion
@NotNull static <T> @NotNull StructCodec<T> RegistryTaggedUnion(@NotNull @NotNull Registry<StructCodec<? extends T>> registry, @NotNull @NotNull Function<T, StructCodec<? extends T>> serializerGetter, @NotNull @NotNull String key) -
RegistryTaggedUnion
@NotNull static <T> @NotNull StructCodec<T> RegistryTaggedUnion(@NotNull Registries.Selector<StructCodec<? extends T>> registrySelector, @NotNull @NotNull Function<T, StructCodec<? extends T>> serializerGetter, @NotNull @NotNull String key) -
Either
-
optional
-
optional
-
transform
@NotNull default <S> @NotNull Codec<S> transform(@NotNull @NotNull ThrowingFunction<T, S> to, @NotNull @NotNull ThrowingFunction<S, T> from) -
list
-
list
-
listOrSingle
-
listOrSingle
-
set
-
set
-
mapValue
-
mapValue
-
unionType
default <R,T1 extends T, StructCodec<R> unionTypeTR extends R> (@NotNull @NotNull Function<T, StructCodec<TR>> serializers, @NotNull @NotNull Function<R, T1> keyFunc) -
unionType
default <R,T1 extends T, StructCodec<R> unionTypeTR extends R> (@NotNull @NotNull String keyField, @NotNull @NotNull Function<T, StructCodec<TR>> serializers, @NotNull @NotNull Function<R, T1> keyFunc) -
orElse
-