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 agp
intermediary net/minecraft/class_5699
named net/minecraft/util/dynamic/Codecs
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate 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
-
Constructor Summary
-
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 forEither
instances.
-
Field Details
-
NONNEGATIVE_INT
- Mappings:
Namespace Name Mixin selector official a
Lagp;a: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 b
Lagp;b: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;
-
-
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 forEither
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
Lagp;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;
-
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 a
Lagp;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 createRangeChecker
Lnet/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 a
Lagp;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;
-
createNonEmptyListChecker
public static <T> Function<List<T>,com.mojang.serialization.DataResult<List<T>>> createNonEmptyListChecker()- Mappings:
Namespace Name Mixin selector official a
Lagp;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
Lagp;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;
-
createPresentValuesChecker
public static <T> Function<List<Supplier<T>>,com.mojang.serialization.DataResult<List<Supplier<T>>>> createPresentValuesChecker()- Mappings:
Namespace Name Mixin selector official b
Lagp;b()Ljava/util/function/Function;
intermediary method_37351
Lnet/minecraft/class_5699;method_37351()Ljava/util/function/Function;
named createPresentValuesChecker
Lnet/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 c
Lagp;c()Ljava/util/function/Function;
intermediary method_37352
Lnet/minecraft/class_5699;method_37352()Ljava/util/function/Function;
named createPresentValueChecker
Lnet/minecraft/util/dynamic/Codecs;createPresentValueChecker()Ljava/util/function/Function;
-