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 agpintermediary net/minecraft/class_5699named net/minecraft/util/dynamic/Codecs
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classCodecs.Xor<F,S> An xor codec that only permits exactly one of the two data choices to be present. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static <N extends Number & Comparable<N>>
Function<N,com.mojang.serialization.DataResult<N>> createRangeChecker(N min, N max, Function<N, String> messageFactory) static <T> com.mojang.serialization.Codec<List<T>>nonEmptyList(com.mojang.serialization.Codec<List<T>> originalCodec) private static com.mojang.serialization.Codec<Integer>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 forEitherinstances.
-
Field Details
-
NONNEGATIVE_INT
- Mappings:
Namespace Name Mixin selector official aLagp;a:Lcom/mojang/serialization/Codec;intermediary field_33441Lnet/minecraft/class_5699;field_33441:Lcom/mojang/serialization/Codec;named NONNEGATIVE_INTLnet/minecraft/util/dynamic/Codecs;NONNEGATIVE_INT:Lcom/mojang/serialization/Codec;
-
POSITIVE_INT
- Mappings:
Namespace Name Mixin selector official bLagp;b:Lcom/mojang/serialization/Codec;intermediary field_33442Lnet/minecraft/class_5699;field_33442:Lcom/mojang/serialization/Codec;named POSITIVE_INTLnet/minecraft/util/dynamic/Codecs;POSITIVE_INT:Lcom/mojang/serialization/Codec;
-
-
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 forEitherinstances.This returned codec fails if both the
firstandsecondcodecs can decode the input, while DFU'sEitherCodecwill 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 aLagp;a(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;intermediary method_33817Lnet/minecraft/class_5699;method_33817(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;named xorLnet/minecraft/util/dynamic/Codecs;xor(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
createRangeChecker
private static <N extends Number & Comparable<N>> Function<N,com.mojang.serialization.DataResult<N>> createRangeChecker(N min, N max, Function<N, String> messageFactory) - Mappings:
Namespace Name Mixin selector official aLagp;a(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;intermediary method_36243Lnet/minecraft/class_5699;method_36243(Ljava/lang/Number;Ljava/lang/Number;Ljava/util/function/Function;)Ljava/util/function/Function;named createRangeCheckerLnet/minecraft/util/dynamic/Codecs;createRangeChecker(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 aLagp;a(IILjava/util/function/Function;)Lcom/mojang/serialization/Codec;intermediary method_36241Lnet/minecraft/class_5699;method_36241(IILjava/util/function/Function;)Lcom/mojang/serialization/Codec;named rangedIntLnet/minecraft/util/dynamic/Codecs;rangedInt(IILjava/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 aLagp;a()Ljava/util/function/Function;intermediary method_36240Lnet/minecraft/class_5699;method_36240()Ljava/util/function/Function;named createNonEmptyListCheckerLnet/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 aLagp;a(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;intermediary method_36973Lnet/minecraft/class_5699;method_36973(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;named nonEmptyListLnet/minecraft/util/dynamic/Codecs;nonEmptyList(Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
-
createPresentValuesChecker
public static <T> Function<List<Supplier<T>>,com.mojang.serialization.DataResult<List<Supplier<T>>>> createPresentValuesChecker()- Mappings:
Namespace Name Mixin selector official bLagp;b()Ljava/util/function/Function;intermediary method_37351Lnet/minecraft/class_5699;method_37351()Ljava/util/function/Function;named createPresentValuesCheckerLnet/minecraft/util/dynamic/Codecs;createPresentValuesChecker()Ljava/util/function/Function;
-
createPresentValueChecker
public static <T> Function<Supplier<T>,com.mojang.serialization.DataResult<Supplier<T>>> createPresentValueChecker()- Mappings:
Namespace Name Mixin selector official cLagp;c()Ljava/util/function/Function;intermediary method_37352Lnet/minecraft/class_5699;method_37352()Ljava/util/function/Function;named createPresentValueCheckerLnet/minecraft/util/dynamic/Codecs;createPresentValueChecker()Ljava/util/function/Function;
-