Class RegistryCodec<E>

java.lang.Object
net.minecraft.util.dynamic.RegistryCodec<E>
Type Parameters:
E - the registry's element type
All Implemented Interfaces:
com.mojang.serialization.Codec<SimpleRegistry<E>>, com.mojang.serialization.Decoder<SimpleRegistry<E>>, com.mojang.serialization.Encoder<SimpleRegistry<E>>

public final class RegistryCodec<E>
extends Object
implements com.mojang.serialization.Codec<SimpleRegistry<E>>
A codec for SimpleRegistry.

Compared to regular codec, this codec performs additional work when decoding, loading its elements from the given resource manager's JSON files.

See Also:
RegistryElementCodec, RegistryOps
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.mojang.serialization.Codec

    com.mojang.serialization.Codec.ResultFunction<A extends Object>

    Nested classes/interfaces inherited from interface com.mojang.serialization.Decoder

    com.mojang.serialization.Decoder.Boxed<A extends Object>, com.mojang.serialization.Decoder.Simple<A extends Object>, com.mojang.serialization.Decoder.Terminal<A extends Object>
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private com.mojang.serialization.Codec<SimpleRegistry<E>> delegate  
    private com.mojang.serialization.MapCodec<E> elementCodec  
    private RegistryKey<Registry<E>> registryRef  

    Fields inherited from interface com.mojang.serialization.Codec

    BOOL, BYTE, BYTE_BUFFER, DOUBLE, EMPTY, FLOAT, INT, INT_STREAM, LONG, LONG_STREAM, PASSTHROUGH, SHORT, STRING
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    private RegistryCodec​(RegistryKey<Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.MapCodec<E> mapCodec)  
  • Method Summary

    Modifier and Type Method Description
    <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<SimpleRegistry<E>,​T>> decode​(com.mojang.serialization.DynamicOps<T> ops, T input)  
    <T> com.mojang.serialization.DataResult<T> encode​(SimpleRegistry<E> simpleRegistry, com.mojang.serialization.DynamicOps<T> dynamicOps, T t)  
    static <E> RegistryCodec<E> of​(RegistryKey<Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.MapCodec<E> mapCodec)  
    String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.mojang.serialization.Codec

    comapFlatMap, deprecated, dispatch, dispatch, dispatchDeprecated, dispatchDeprecated, dispatchDeprecatedMap, dispatchDeprecatedMap, dispatchMap, dispatchMap, dispatchStable, dispatchStable, dispatchStableMap, dispatchStableMap, fieldOf, flatComapMap, flatXmap, listOf, mapResult, optionalFieldOf, optionalFieldOf, optionalFieldOf, optionalFieldOf, partialDispatch, partialDispatchMap, promotePartial, stable, withDefault, withDefault, withDefault, withDefault, withDefault, withDefault, withLifecycle, xmap

    Methods inherited from interface com.mojang.serialization.Decoder

    boxed, decode, flatMap, map, parse, parse, simple, terminal

    Methods inherited from interface com.mojang.serialization.Encoder

    comap, encodeStart, flatComap
  • Field Details

  • Constructor Details

    • RegistryCodec

      private RegistryCodec​(RegistryKey<Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.MapCodec<E> mapCodec)
  • Method Details

    • of

      public static <E> RegistryCodec<E> of​(RegistryKey<Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.MapCodec<E> mapCodec)
    • encode

      public <T> com.mojang.serialization.DataResult<T> encode​(SimpleRegistry<E> simpleRegistry, com.mojang.serialization.DynamicOps<T> dynamicOps, T t)
      Specified by:
      encode in interface com.mojang.serialization.Encoder<E>
    • decode

      public <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<SimpleRegistry<E>,​T>> decode​(com.mojang.serialization.DynamicOps<T> ops, T input)
      Specified by:
      decode in interface com.mojang.serialization.Decoder<E>
    • toString

      public String toString()
      Overrides:
      toString in class Object