Package net.minecraft.util.dynamic
Class Codecs
java.lang.Object
net.minecraft.util.dynamic.Codecs
A few extensions for
Codec
or DynamicOps
.
It has a few methods to create checkers for Codec.flatXmap
to add
extra value validation to encoding and decoding. See the implementation of
nonEmptyList(Codec)
.
- Mappings:
Namespace Name official alq
intermediary net/minecraft/class_5699
named net/minecraft/util/dynamic/Codecs
-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
private static final class
private static final record
static final record
private static final class
Codecs.Xor<F,
S> An xor codec that only permits exactly one of the two data choices to be present. -
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<byte[]>
static final com.mojang.serialization.Codec<Instant>
static final com.mojang.serialization.Codec<Integer>
static final Function<OptionalLong,
Optional<Long>> static final Function<Optional<Long>,
OptionalLong> static final com.mojang.serialization.Codec<Float>
static final com.mojang.serialization.Codec<Integer>
static final com.mojang.serialization.Codec<Pattern>
static final com.mojang.serialization.Codec<Codecs.TagEntryId>
static final com.mojang.serialization.Codec<UUID>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P,
I> com.mojang.serialization.Codec<I> createCodecForPairObject
(com.mojang.serialization.Codec<P> codec, String leftFieldName, String rightFieldName, BiFunction<P, P, com.mojang.serialization.DataResult<I>> combineFunction, Function<I, P> leftFunction, Function<I, P> rightFunction) static <E> com.mojang.serialization.MapCodec<E>
createContextRetrievalCodec
(Function<com.mojang.serialization.DynamicOps<?>, com.mojang.serialization.DataResult<E>> retriever) static <E,
L extends Collection<E>, T>
Function<L,com.mojang.serialization.DataResult<L>> createEqualTypeChecker
(Function<E, T> typeGetter) private static <N extends Number & Comparable<N>>
Function<N,com.mojang.serialization.DataResult<N>> createFloatRangeChecker
(N min, N max, Function<N, String> messageFactory) private static <N extends Number & Comparable<N>>
Function<N,com.mojang.serialization.DataResult<N>> createIntRangeChecker
(N min, N max, Function<N, String> messageFactory) static <A> com.mojang.serialization.Codec<A>
createLazy
(Supplier<com.mojang.serialization.Codec<A>> supplier) static <T> Function<RegistryEntryList<T>,
com.mojang.serialization.DataResult<RegistryEntryList<T>>> static <A> com.mojang.serialization.Codec<A>
exceptionCatching
(com.mojang.serialization.Codec<A> codec) static <E> com.mojang.serialization.Codec<E>
static com.mojang.serialization.Codec<Instant>
instant
(DateTimeFormatter formatter) static <T> com.mojang.serialization.Codec<RegistryEntryList<T>>
nonEmptyEntryList
(com.mojang.serialization.Codec<RegistryEntryList<T>> originalCodec) static <T> com.mojang.serialization.Codec<List<T>>
nonEmptyList
(com.mojang.serialization.Codec<List<T>> originalCodec) static com.mojang.serialization.MapCodec<OptionalLong>
optionalLong
(com.mojang.serialization.MapCodec<Optional<Long>> codec) static <E> com.mojang.serialization.Codec<E>
orCompressed
(com.mojang.serialization.Codec<E> uncompressedCodec, com.mojang.serialization.Codec<E> compressedCodec) static <A> com.mojang.serialization.Codec.ResultFunction<A>
orElsePartial
(A object) private static com.mojang.serialization.Codec<Float>
rangedFloat
(float min, float max, Function<Float, String> messageFactory) private static com.mojang.serialization.Codec<Integer>
static <E> com.mojang.serialization.Codec<E>
rawIdChecked
(ToIntFunction<E> elementToRawId, IntFunction<E> rawIdToElement, int errorRawId) static <E> com.mojang.serialization.Codec<E>
withLifecycle
(com.mojang.serialization.Codec<E> originalCodec, Function<E, com.mojang.serialization.Lifecycle> entryLifecycleGetter, Function<E, com.mojang.serialization.Lifecycle> lifecycleGetter) static <F,
S> com.mojang.serialization.Codec<com.mojang.datafixers.util.Either<F, S>> xor
(com.mojang.serialization.Codec<F> first, com.mojang.serialization.Codec<S> second) Returns an exclusive-or codec forCodecs.Either
instances.
-
Field Details
-
UUID
- Mappings:
Namespace Name Mixin selector official a
Lalq;a:Lcom/mojang/serialization/Codec;
intermediary field_38081
Lnet/minecraft/class_5699;field_38081:Lcom/mojang/serialization/Codec;
named UUID
Lnet/minecraft/util/dynamic/Codecs;UUID:Lcom/mojang/serialization/Codec;
-
NONNEGATIVE_INT
- Mappings:
Namespace Name Mixin selector official b
Lalq;b:Lcom/mojang/serialization/Codec;
intermediary field_33441
Lnet/minecraft/class_5699;field_33441:Lcom/mojang/serialization/Codec;
named NONNEGATIVE_INT
Lnet/minecraft/util/dynamic/Codecs;NONNEGATIVE_INT:Lcom/mojang/serialization/Codec;
-
POSITIVE_INT
- Mappings:
Namespace Name Mixin selector official c
Lalq;c:Lcom/mojang/serialization/Codec;
intermediary field_33442
Lnet/minecraft/class_5699;field_33442:Lcom/mojang/serialization/Codec;
named POSITIVE_INT
Lnet/minecraft/util/dynamic/Codecs;POSITIVE_INT:Lcom/mojang/serialization/Codec;
-
POSITIVE_FLOAT
- Mappings:
Namespace Name Mixin selector official d
Lalq;d:Lcom/mojang/serialization/Codec;
intermediary field_34387
Lnet/minecraft/class_5699;field_34387:Lcom/mojang/serialization/Codec;
named POSITIVE_FLOAT
Lnet/minecraft/util/dynamic/Codecs;POSITIVE_FLOAT:Lcom/mojang/serialization/Codec;
-
REGULAR_EXPRESSION
- Mappings:
Namespace Name Mixin selector official e
Lalq;e:Lcom/mojang/serialization/Codec;
intermediary field_37408
Lnet/minecraft/class_5699;field_37408:Lcom/mojang/serialization/Codec;
named REGULAR_EXPRESSION
Lnet/minecraft/util/dynamic/Codecs;REGULAR_EXPRESSION:Lcom/mojang/serialization/Codec;
-
INSTANT
- Mappings:
Namespace Name Mixin selector official f
Lalq;f:Lcom/mojang/serialization/Codec;
intermediary field_39042
Lnet/minecraft/class_5699;field_39042:Lcom/mojang/serialization/Codec;
named INSTANT
Lnet/minecraft/util/dynamic/Codecs;INSTANT:Lcom/mojang/serialization/Codec;
-
BASE_64
public static final com.mojang.serialization.Codec<byte[]> BASE_64- Mappings:
Namespace Name Mixin selector official g
Lalq;g:Lcom/mojang/serialization/Codec;
intermediary field_39273
Lnet/minecraft/class_5699;field_39273:Lcom/mojang/serialization/Codec;
named BASE_64
Lnet/minecraft/util/dynamic/Codecs;BASE_64:Lcom/mojang/serialization/Codec;
-
TAG_ENTRY_ID
- Mappings:
Namespace Name Mixin selector official h
Lalq;h:Lcom/mojang/serialization/Codec;
intermediary field_39274
Lnet/minecraft/class_5699;field_39274:Lcom/mojang/serialization/Codec;
named TAG_ENTRY_ID
Lnet/minecraft/util/dynamic/Codecs;TAG_ENTRY_ID:Lcom/mojang/serialization/Codec;
-
OPTIONAL_OF_LONG_TO_OPTIONAL_LONG
- Mappings:
Namespace Name Mixin selector official i
Lalq;i:Ljava/util/function/Function;
intermediary field_39395
Lnet/minecraft/class_5699;field_39395:Ljava/util/function/Function;
named OPTIONAL_OF_LONG_TO_OPTIONAL_LONG
Lnet/minecraft/util/dynamic/Codecs;OPTIONAL_OF_LONG_TO_OPTIONAL_LONG:Ljava/util/function/Function;
-
OPTIONAL_LONG_TO_OPTIONAL_OF_LONG
- Mappings:
Namespace Name Mixin selector official j
Lalq;j:Ljava/util/function/Function;
intermediary field_39396
Lnet/minecraft/class_5699;field_39396:Ljava/util/function/Function;
named OPTIONAL_LONG_TO_OPTIONAL_OF_LONG
Lnet/minecraft/util/dynamic/Codecs;OPTIONAL_LONG_TO_OPTIONAL_OF_LONG:Ljava/util/function/Function;
-
-
Constructor Details
-
Codecs
public Codecs()
-
-
Method Details
-
xor
public static <F,S> com.mojang.serialization.Codec<com.mojang.datafixers.util.Either<F,S>> xor(com.mojang.serialization.Codec<F> first, com.mojang.serialization.Codec<S> second) Returns an exclusive-or codec forCodecs.Either
instances.This returned codec fails if both the
first
andsecond
codecs can decode the input, while DFU'sEitherCodec
will always take the first decoded result when it is available.Otherwise, this behaves the same as the either codec.
- Type Parameters:
F
- the first typeS
- the second type- Parameters:
first
- the first codecsecond
- the second codec- Returns:
- the xor codec for the two codecs
- See Also:
-
Codec.either(Codec, Codec)
EitherCodec
- Mappings:
Namespace Name Mixin selector official a
Lalq;a(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
intermediary method_33817
Lnet/minecraft/class_5699;method_33817(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
named xor
Lnet/minecraft/util/dynamic/Codecs;xor(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
createCodecForPairObject
public static <P,I> com.mojang.serialization.Codec<I> createCodecForPairObject(com.mojang.serialization.Codec<P> codec, String leftFieldName, String rightFieldName, BiFunction<P, P, com.mojang.serialization.DataResult<I>> combineFunction, Function<I, P> leftFunction, Function<I, P> rightFunction) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Lcom/mojang/serialization/Codec;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/BiFunction;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
intermediary method_37931
Lnet/minecraft/class_5699;method_37931(Lcom/mojang/serialization/Codec;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/BiFunction;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
named createCodecForPairObject
Lnet/minecraft/util/dynamic/Codecs;createCodecForPairObject(Lcom/mojang/serialization/Codec;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/BiFunction;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
-
orElsePartial
public static <A> com.mojang.serialization.Codec.ResultFunction<A> orElsePartial(A object) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/lang/Object;)Lcom/mojang/serialization/Codec$ResultFunction;
intermediary method_39028
Lnet/minecraft/class_5699;method_39028(Ljava/lang/Object;)Lcom/mojang/serialization/Codec$ResultFunction;
named orElsePartial
Lnet/minecraft/util/dynamic/Codecs;orElsePartial(Ljava/lang/Object;)Lcom/mojang/serialization/Codec$ResultFunction;
-
rawIdChecked
public static <E> com.mojang.serialization.Codec<E> rawIdChecked(ToIntFunction<E> elementToRawId, IntFunction<E> rawIdToElement, int errorRawId) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/util/function/ToIntFunction;Ljava/util/function/IntFunction;I)Lcom/mojang/serialization/Codec;
intermediary method_39511
Lnet/minecraft/class_5699;method_39511(Ljava/util/function/ToIntFunction;Ljava/util/function/IntFunction;I)Lcom/mojang/serialization/Codec;
named rawIdChecked
Lnet/minecraft/util/dynamic/Codecs;rawIdChecked(Ljava/util/function/ToIntFunction;Ljava/util/function/IntFunction;I)Lcom/mojang/serialization/Codec;
-
idChecked
public static <E> com.mojang.serialization.Codec<E> idChecked(Function<E, String> elementToId, Function<String, E> idToElement) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
intermediary method_39508
Lnet/minecraft/class_5699;method_39508(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
named idChecked
Lnet/minecraft/util/dynamic/Codecs;idChecked(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
-
orCompressed
public static <E> com.mojang.serialization.Codec<E> orCompressed(com.mojang.serialization.Codec<E> uncompressedCodec, com.mojang.serialization.Codec<E> compressedCodec) - Mappings:
Namespace Name Mixin selector official b
Lalq;b(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
intermediary method_39512
Lnet/minecraft/class_5699;method_39512(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
named orCompressed
Lnet/minecraft/util/dynamic/Codecs;orCompressed(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
withLifecycle
public static <E> com.mojang.serialization.Codec<E> withLifecycle(com.mojang.serialization.Codec<E> originalCodec, Function<E, com.mojang.serialization.Lifecycle> entryLifecycleGetter, Function<E, com.mojang.serialization.Lifecycle> lifecycleGetter) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Lcom/mojang/serialization/Codec;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
intermediary method_39504
Lnet/minecraft/class_5699;method_39504(Lcom/mojang/serialization/Codec;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
named withLifecycle
Lnet/minecraft/util/dynamic/Codecs;withLifecycle(Lcom/mojang/serialization/Codec;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
-
createIntRangeChecker
private static <N extends Number & Comparable<N>> Function<N,com.mojang.serialization.DataResult<N>> createIntRangeChecker(N min, N max, Function<N, String> messageFactory) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
intermediary method_36243
Lnet/minecraft/class_5699;method_36243(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
named createIntRangeChecker
Lnet/minecraft/util/dynamic/Codecs;createIntRangeChecker(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
-
rangedInt
private static com.mojang.serialization.Codec<Integer> rangedInt(int min, int max, Function<Integer, String> messageFactory) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(IILjava/util/function/Function;)Lcom/mojang/serialization/Codec;
intermediary method_36241
Lnet/minecraft/class_5699;method_36241(IILjava/util/function/Function;)Lcom/mojang/serialization/Codec;
named rangedInt
Lnet/minecraft/util/dynamic/Codecs;rangedInt(IILjava/util/function/Function;)Lcom/mojang/serialization/Codec;
-
createFloatRangeChecker
private static <N extends Number & Comparable<N>> Function<N,com.mojang.serialization.DataResult<N>> createFloatRangeChecker(N min, N max, Function<N, String> messageFactory) - Mappings:
Namespace Name Mixin selector official b
Lalq;b(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
intermediary method_37940
Lnet/minecraft/class_5699;method_37940(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
named createFloatRangeChecker
Lnet/minecraft/util/dynamic/Codecs;createFloatRangeChecker(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;
-
rangedFloat
private static com.mojang.serialization.Codec<Float> rangedFloat(float min, float max, Function<Float, String> messageFactory) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(FFLjava/util/function/Function;)Lcom/mojang/serialization/Codec;
intermediary method_37928
Lnet/minecraft/class_5699;method_37928(FFLjava/util/function/Function;)Lcom/mojang/serialization/Codec;
named rangedFloat
Lnet/minecraft/util/dynamic/Codecs;rangedFloat(FFLjava/util/function/Function;)Lcom/mojang/serialization/Codec;
-
createNonEmptyListChecker
public static <T> Function<List<T>,com.mojang.serialization.DataResult<List<T>>> createNonEmptyListChecker()- Mappings:
Namespace Name Mixin selector official a
Lalq;a()Ljava/util/function/Function;
intermediary method_36240
Lnet/minecraft/class_5699;method_36240()Ljava/util/function/Function;
named createNonEmptyListChecker
Lnet/minecraft/util/dynamic/Codecs;createNonEmptyListChecker()Ljava/util/function/Function;
-
nonEmptyList
public static <T> com.mojang.serialization.Codec<List<T>> nonEmptyList(com.mojang.serialization.Codec<List<T>> originalCodec) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
intermediary method_36973
Lnet/minecraft/class_5699;method_36973(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
named nonEmptyList
Lnet/minecraft/util/dynamic/Codecs;nonEmptyList(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
createNonEmptyEntryListChecker
public static <T> Function<RegistryEntryList<T>,com.mojang.serialization.DataResult<RegistryEntryList<T>>> createNonEmptyEntryListChecker()- Mappings:
Namespace Name Mixin selector official b
Lalq;b()Ljava/util/function/Function;
intermediary method_40112
Lnet/minecraft/class_5699;method_40112()Ljava/util/function/Function;
named createNonEmptyEntryListChecker
Lnet/minecraft/util/dynamic/Codecs;createNonEmptyEntryListChecker()Ljava/util/function/Function;
-
nonEmptyEntryList
public static <T> com.mojang.serialization.Codec<RegistryEntryList<T>> nonEmptyEntryList(com.mojang.serialization.Codec<RegistryEntryList<T>> originalCodec) - Mappings:
Namespace Name Mixin selector official b
Lalq;b(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
intermediary method_40113
Lnet/minecraft/class_5699;method_40113(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
named nonEmptyEntryList
Lnet/minecraft/util/dynamic/Codecs;nonEmptyEntryList(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
createLazy
public static <A> com.mojang.serialization.Codec<A> createLazy(Supplier<com.mojang.serialization.Codec<A>> supplier) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/util/function/Supplier;)Lcom/mojang/serialization/Codec;
intermediary method_39240
Lnet/minecraft/class_5699;method_39240(Ljava/util/function/Supplier;)Lcom/mojang/serialization/Codec;
named createLazy
Lnet/minecraft/util/dynamic/Codecs;createLazy(Ljava/util/function/Supplier;)Lcom/mojang/serialization/Codec;
-
createContextRetrievalCodec
public static <E> com.mojang.serialization.MapCodec<E> createContextRetrievalCodec(Function<com.mojang.serialization.DynamicOps<?>, com.mojang.serialization.DataResult<E>> retriever) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/util/function/Function;)Lcom/mojang/serialization/MapCodec;
intermediary method_40110
Lnet/minecraft/class_5699;method_40110(Ljava/util/function/Function;)Lcom/mojang/serialization/MapCodec;
named createContextRetrievalCodec
Lnet/minecraft/util/dynamic/Codecs;createContextRetrievalCodec(Ljava/util/function/Function;)Lcom/mojang/serialization/MapCodec;
-
createEqualTypeChecker
public static <E,L extends Collection<E>, Function<L,T> com.mojang.serialization.DataResult<L>> createEqualTypeChecker(Function<E, T> typeGetter) - Mappings:
Namespace Name Mixin selector official b
Lalq;b(Ljava/util/function/Function;)Ljava/util/function/Function;
intermediary method_40114
Lnet/minecraft/class_5699;method_40114(Ljava/util/function/Function;)Ljava/util/function/Function;
named createEqualTypeChecker
Lnet/minecraft/util/dynamic/Codecs;createEqualTypeChecker(Ljava/util/function/Function;)Ljava/util/function/Function;
-
exceptionCatching
public static <A> com.mojang.serialization.Codec<A> exceptionCatching(com.mojang.serialization.Codec<A> codec) - Mappings:
Namespace Name Mixin selector official c
Lalq;c(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
intermediary method_42114
Lnet/minecraft/class_5699;method_42114(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
named exceptionCatching
Lnet/minecraft/util/dynamic/Codecs;exceptionCatching(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
instant
- Mappings:
Namespace Name Mixin selector official a
Lalq;a(Ljava/time/format/DateTimeFormatter;)Lcom/mojang/serialization/Codec;
intermediary method_43532
Lnet/minecraft/class_5699;method_43532(Ljava/time/format/DateTimeFormatter;)Lcom/mojang/serialization/Codec;
named instant
Lnet/minecraft/util/dynamic/Codecs;instant(Ljava/time/format/DateTimeFormatter;)Lcom/mojang/serialization/Codec;
-
optionalLong
public static com.mojang.serialization.MapCodec<OptionalLong> optionalLong(com.mojang.serialization.MapCodec<Optional<Long>> codec) - Mappings:
Namespace Name Mixin selector official a
Lalq;a(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/MapCodec;
intermediary method_44167
Lnet/minecraft/class_5699;method_44167(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/MapCodec;
named optionalLong
Lnet/minecraft/util/dynamic/Codecs;optionalLong(Lcom/mojang/serialization/MapCodec;)Lcom/mojang/serialization/MapCodec;
-