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:
Mappings:
Namespace Name
official xu
intermediary net/minecraft/class_5380
named net/minecraft/util/dynamic/RegistryCodec
  • 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 final com.mojang.serialization.Codec<SimpleRegistry<E>>
     
    private final com.mojang.serialization.Codec<E>
     
    private final RegistryKey<? extends Registry<E>>
     

    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<? extends Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.Codec<E> codec)
     
  • 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<? extends Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.Codec<E> codec)
     
     

    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, dispatchMap, dispatchMap, dispatchStable, fieldOf, flatComapMap, flatXmap, listOf, mapResult, optionalFieldOf, optionalFieldOf, optionalFieldOf, optionalFieldOf, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, partialDispatch, promotePartial, stable, 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

    • delegate

      private final com.mojang.serialization.Codec<SimpleRegistry<E>> delegate
      Mappings:
      Namespace Name Mixin selector
      official a Lxu;a:Lcom/mojang/serialization/Codec;
      intermediary field_25504 Lnet/minecraft/class_5380;field_25504:Lcom/mojang/serialization/Codec;
      named delegate Lnet/minecraft/util/dynamic/RegistryCodec;delegate:Lcom/mojang/serialization/Codec;
    • registryRef

      private final RegistryKey<? extends Registry<E>> registryRef
      Mappings:
      Namespace Name Mixin selector
      official b Lxu;b:Lya;
      intermediary field_25505 Lnet/minecraft/class_5380;field_25505:Lnet/minecraft/class_5321;
      named registryRef Lnet/minecraft/util/dynamic/RegistryCodec;registryRef:Lnet/minecraft/util/registry/RegistryKey;
    • elementCodec

      private final com.mojang.serialization.Codec<E> elementCodec
      Mappings:
      Namespace Name Mixin selector
      official c Lxu;c:Lcom/mojang/serialization/Codec;
      intermediary field_25506 Lnet/minecraft/class_5380;field_25506:Lcom/mojang/serialization/Codec;
      named elementCodec Lnet/minecraft/util/dynamic/RegistryCodec;elementCodec:Lcom/mojang/serialization/Codec;
  • Constructor Details

    • RegistryCodec

      private RegistryCodec(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.Codec<E> codec)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lxu;<init>(Lya;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)V
      intermediary <init> Lnet/minecraft/class_5380;<init>(Lnet/minecraft/class_5321;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)V
      named <init> Lnet/minecraft/util/dynamic/RegistryCodec;<init>(Lnet/minecraft/util/registry/RegistryKey;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)V
  • Method Details

    • of

      public static <E> RegistryCodec<E> of(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Lifecycle lifecycle, com.mojang.serialization.Codec<E> codec)
      Mappings:
      Namespace Name Mixin selector
      official a Lxu;a(Lya;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)Lxu;
      intermediary method_29745 Lnet/minecraft/class_5380;method_29745(Lnet/minecraft/class_5321;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)Lnet/minecraft/class_5380;
      named of Lnet/minecraft/util/dynamic/RegistryCodec;of(Lnet/minecraft/util/registry/RegistryKey;Lcom/mojang/serialization/Lifecycle;Lcom/mojang/serialization/Codec;)Lnet/minecraft/util/dynamic/RegistryCodec;
    • 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>
      Mappings:
      Namespace Name Mixin selector
      official a Lxu;a(Lgs;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
      intermediary method_29744 Lnet/minecraft/class_5380;method_29744(Lnet/minecraft/class_2370;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
      named encode Lnet/minecraft/util/dynamic/RegistryCodec;encode(Lnet/minecraft/util/registry/SimpleRegistry;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
    • 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>
      Mappings:
      Namespace Name Mixin selector
      official decode Lxu;decode(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
      intermediary decode Lnet/minecraft/class_5380;decode(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
      named decode Lnet/minecraft/util/dynamic/RegistryCodec;decode(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;
    • toString

      public String toString()
      Overrides:
      toString in class Object