Class MapCodec<A>

java.lang.Object
com.mojang.serialization.CompressorHolder
com.mojang.serialization.MapCodec<A>
Type Parameters:
A - The type to convert
All Implemented Interfaces:
Compressable, Keyable, MapDecoder<A>, MapEncoder<A>
Direct Known Subclasses:
EitherMapCodec, KeyDispatchCodec, OptionalFieldCodec, PairMapCodec, SimpleMapCodec

public abstract class MapCodec<A> extends CompressorHolder implements MapDecoder<A>, MapEncoder<A>
A combined MapEncoder and MapDecoder which can convert objects to and from a series of fields. A MapCodec consists of a fixed set of optional fields, can read those fields from a MapLike object, and can write those fields to a RecordBuilder object. A MapCodec can be used to create a Codec by calling codec(); this codec will encode the map's fields to a map created by a DynamicOps instance. unless the ops have DynamicOps.compressMaps(), in which case the map will be encoded in a "compressed" map - in other words, as a list of values, where the index of the value in the list corresponds to the index of the (potentially optional) key in the stream returned by keys(DynamicOps). Codecs created by codec() are occasionally treated specially by other codec constructions.