Class TCodec

java.lang.Object
com.thecsdev.commonmc.api.serialization.TCodec

public final class TCodec extends Object
Utility Codec implementations and functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<URI>
    Codec for URIs.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <A> @NotNull com.mojang.serialization.Codec<List<A>>
    lenientListOf(@NotNull com.mojang.serialization.Codec<A> codec)
    Returns a Codec for a List of elements, that is lenient when encoding/decoding, and simply ignores any elements that fail to encode/decode instead of returning an error for the entire List.
    static <K,V> @NotNull com.mojang.serialization.Codec<Map<K,V>>
    lenientMap(@NotNull com.mojang.serialization.Codec<K> keyCodec, @NotNull com.mojang.serialization.Codec<V> valueCodec)
    Returns a Codec for a Map, that is lenient when encoding/decoding, and simply ignores any key-value pairs that fail to encode/decode instead of returning an error for the entire Map.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • URI

      public static final com.mojang.serialization.Codec<URI> URI
      Codec for URIs.
  • Method Details

    • lenientListOf

      @NotNull public static <A> @NotNull com.mojang.serialization.Codec<List<A>> lenientListOf(@NotNull @NotNull com.mojang.serialization.Codec<A> codec) throws NullPointerException
      Returns a Codec for a List of elements, that is lenient when encoding/decoding, and simply ignores any elements that fail to encode/decode instead of returning an error for the entire List.
      Type Parameters:
      A - The list's element type.
      Parameters:
      codec - The Codec for the list's element type.
      Throws:
      NullPointerException - If the argument is null.
    • lenientMap

      @NotNull public static <K,V> @NotNull com.mojang.serialization.Codec<Map<K,V>> lenientMap(@NotNull @NotNull com.mojang.serialization.Codec<K> keyCodec, @NotNull @NotNull com.mojang.serialization.Codec<V> valueCodec) throws NullPointerException
      Returns a Codec for a Map, that is lenient when encoding/decoding, and simply ignores any key-value pairs that fail to encode/decode instead of returning an error for the entire Map.
      Type Parameters:
      K - The Map's key type.
      V - The Map's value type.
      Parameters:
      keyCodec - The Codec for the map's key type.
      valueCodec - The Codec for the map's value type.
      Throws:
      NullPointerException - If an argument is null.