Class MinecraftSerializers
- java.lang.Object
-
- ca.stellardrift.confabricate.typeserializers.MinecraftSerializers
-
public final class MinecraftSerializers extends Object
Access serializers for Minecraft types.The
collection()provides an easily accessible collection of built-in type serializers, while other factory methods allow creating custom type serializers that interact with game serialization mechanisms.- Since:
- 1.2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> @Nullable com.mojang.serialization.Codec<S>codec(io.leangen.geantyref.TypeToken<S> type)Create a new codec that uses the default type serializer collection to serialize an object of the provided type.static <V> @Nullable com.mojang.serialization.Codec<V>codec(io.leangen.geantyref.TypeToken<V> type, TypeSerializerCollection collection)Create a new codec based on a ConfigurateTypeSerializer.static TypeSerializerCollectioncollection()The default collection of game serializers.static <T> TypeSerializer<T>forRegistry(Registry<T> registry)Create aTypeSerializerthan can interpret values in the provided registry.static booleanisCommonCollection(TypeSerializerCollection collection)Check if a collection is our populated collection without attempting to initialize serializers.static TypeSerializerCollection.Builderpopulate(TypeSerializerCollection.Builder collection)Register MinecraftTypeSerializers with the provided collection.static <V> TypeSerializer<V>serializer(com.mojang.serialization.Codec<V> codec)Create a new serializer wrapping the providedCodec.
-
-
-
Method Detail
-
serializer
public static <V> TypeSerializer<V> serializer(com.mojang.serialization.Codec<V> codec)
Create a new serializer wrapping the providedCodec.- Type Parameters:
V- value type- Parameters:
codec- codec to use for the serialization operation- Returns:
- a new serializer
- Since:
- 2.0.0
- See Also:
for more information
-
codec
public static <S> @Nullable com.mojang.serialization.Codec<S> codec(io.leangen.geantyref.TypeToken<S> type)
Create a new codec that uses the default type serializer collection to serialize an object of the provided type.- Type Parameters:
S- value type- Parameters:
type- token representing a value type- Returns:
- a codec for the type, or null if an appropriate
TypeSerializercould not be found. - Since:
- 2.0.0
- See Also:
for more information
-
codec
public static <V> @Nullable com.mojang.serialization.Codec<V> codec(io.leangen.geantyref.TypeToken<V> type, TypeSerializerCollection collection)
Create a new codec based on a ConfigurateTypeSerializer.- Type Parameters:
V- value type- Parameters:
type- type to serializecollection- source for values- Returns:
- a codec, or null if an appropriate
TypeSerializercould not be found for the TypeToken. - Since:
- 2.0.0
- See Also:
DfuSerializers.codec(TypeToken, TypeSerializerCollection)
-
forRegistry
public static <T> TypeSerializer<T> forRegistry(Registry<T> registry)
Create aTypeSerializerthan can interpret values in the provided registry.- Type Parameters:
T- the type registered by the registry- Parameters:
registry- the registry- Returns:
- a serializer for the registry
- Since:
- 1.2.0
-
collection
public static TypeSerializerCollection collection()
The default collection of game serializers.While the collection is mutable, modifying it is discouraged in favor of working with a new child, created with
TypeSerializerCollection.childBuilder()()}. Collections of serializers will become immutable in Configurate 4.0- Returns:
- minecraft serializers
- Since:
- 1.2.0
- See Also:
for information about which serializers this collection will include
-
isCommonCollection
public static boolean isCommonCollection(TypeSerializerCollection collection)
Check if a collection is our populated collection without attempting to initialize serializers.This helps to integrate with Confabricate in test environments.
- Parameters:
collection- collection to test- Returns:
- if tested collection is the confabricate default collection
- Since:
- 1.2.0
-
populate
public static TypeSerializerCollection.Builder populate(TypeSerializerCollection.Builder collection)
Register MinecraftTypeSerializers with the provided collection.This will add serializers for:
IdentifiersText(as a string)- Any elements in vanilla
registries Tagof a combination of identifiers and tags for blocks, items, fluids, and entity typesItemStackCompoundTaginstances
- Parameters:
collection- to populate- Returns:
- provided collection
- Since:
- 1.2.0
-
-