Class Codecs

java.lang.Object
net.minecraft.util.dynamic.Codecs

public class Codecs extends Object
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 aii
intermediary net/minecraft/class_5699
named net/minecraft/util/dynamic/Codecs
  • Field Details

    • NONNEGATIVE_INT

      public static final com.mojang.serialization.Codec<Integer> NONNEGATIVE_INT
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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

      public static final com.mojang.serialization.Codec<Integer> POSITIVE_INT
      Mappings:
      Namespace Name Mixin selector
      official b Laii;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;
    • POSITIVE_FLOAT

      public static final com.mojang.serialization.Codec<Float> POSITIVE_FLOAT
      Mappings:
      Namespace Name Mixin selector
      official c Laii;c: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;
  • 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 for Codecs.Either instances.

      This returned codec fails if both the first and second codecs can decode the input, while DFU's EitherCodec 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 type
      S - the second type
      Parameters:
      first - the first codec
      second - 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 Laii;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 Laii;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;
    • method_39028

      public static <A> com.mojang.serialization.Codec.ResultFunction<A> method_39028(A a)
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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 method_39028 Lnet/minecraft/util/dynamic/Codecs;method_39028(Ljava/lang/Object;)Lcom/mojang/serialization/Codec$ResultFunction;
    • method_39511

      public static <E> com.mojang.serialization.Codec<E> method_39511(ToIntFunction<E> toIntFunction, IntFunction<E> intFunction, int int2)
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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 method_39511 Lnet/minecraft/util/dynamic/Codecs;method_39511(Ljava/util/function/ToIntFunction;Ljava/util/function/IntFunction;I)Lcom/mojang/serialization/Codec;
    • method_39508

      public static <E> com.mojang.serialization.Codec<E> method_39508(Function<E,String> function, Function<String,E> function2)
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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 method_39508 Lnet/minecraft/util/dynamic/Codecs;method_39508(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;
    • method_39512

      public static <E> com.mojang.serialization.Codec<E> method_39512(com.mojang.serialization.Codec<E> codec, com.mojang.serialization.Codec<E> codec2)
      Mappings:
      Namespace Name Mixin selector
      official b Laii;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 method_39512 Lnet/minecraft/util/dynamic/Codecs;method_39512(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/Codec;
    • method_39504

      public static <E> com.mojang.serialization.Codec<E> method_39504(com.mojang.serialization.Codec<E> codec, Function<E,com.mojang.serialization.Lifecycle> function, Function<E,com.mojang.serialization.Lifecycle> function2)
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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 method_39504 Lnet/minecraft/util/dynamic/Codecs;method_39504(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 Laii;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 Laii;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 Laii;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 Laii;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 Laii;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 Laii;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 Laii;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 Laii;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;
    • createLazy

      public static <A> com.mojang.serialization.Codec<A> createLazy(Supplier<com.mojang.serialization.Codec<A>> supplier)
      Mappings:
      Namespace Name Mixin selector
      official a Laii;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;