Package net.minecraft.util.dynamic
Class RegistryElementCodec<E>
java.lang.Object
net.minecraft.util.dynamic.RegistryElementCodec<E>
- Type Parameters:
E
- the element type
- All Implemented Interfaces:
com.mojang.serialization.Codec<Supplier<E>>
,com.mojang.serialization.Decoder<Supplier<E>>
,com.mojang.serialization.Encoder<Supplier<E>>
public final class RegistryElementCodec<E> extends Object implements com.mojang.serialization.Codec<Supplier<E>>
A codec for registry elements. Will prefer to encode/decode objects as
identifiers if they exist in a registry and falls back to full encoding/
decoding behavior if it cannot do so.
The codec's saves and loads Supplier<E>
in order to avoid early
loading from registry before a registry is fully loaded from a codec.
- See Also:
RegistryCodec
,RegistryReadingOps
,RegistryOps
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mojang.serialization.Codec
com.mojang.serialization.Codec.ResultFunction<A extends Object>
-
Field Summary
Fields Modifier and Type Field Description private com.mojang.serialization.Codec<E>
elementCodec
private boolean
field_26758
private RegistryKey<? extends 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
RegistryElementCodec(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> codec, boolean bool)
-
Method Summary
Modifier and Type Method Description <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<Supplier<E>,T>>
decode(com.mojang.serialization.DynamicOps<T> ops, T input)
<T> com.mojang.serialization.DataResult<T>
encode(Supplier<E> supplier, com.mojang.serialization.DynamicOps<T> dynamicOps, T t)
private static <E> RegistryElementCodec<E>
method_31192(RegistryKey<? extends Registry<E>> registryKey, com.mojang.serialization.Codec<E> codec, boolean bool)
static <E> com.mojang.serialization.Codec<List<Supplier<E>>>
method_31194(RegistryKey<? extends Registry<E>> registryKey, com.mojang.serialization.Codec<E> codec)
static <E> RegistryElementCodec<E>
of(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> codec)
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, 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
-
registryRef
-
elementCodec
-
field_26758
private final boolean field_26758
-
-
Constructor Details
-
RegistryElementCodec
private RegistryElementCodec(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> codec, boolean bool)
-
-
Method Details
-
of
public static <E> RegistryElementCodec<E> of(RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> codec) -
method_31194
public static <E> com.mojang.serialization.Codec<List<Supplier<E>>> method_31194(RegistryKey<? extends Registry<E>> registryKey, com.mojang.serialization.Codec<E> codec) -
method_31192
private static <E> RegistryElementCodec<E> method_31192(RegistryKey<? extends Registry<E>> registryKey, com.mojang.serialization.Codec<E> codec, boolean bool) -
encode
public <T> com.mojang.serialization.DataResult<T> encode(Supplier<E> supplier, com.mojang.serialization.DynamicOps<T> dynamicOps, T t)- Specified by:
encode
in interfacecom.mojang.serialization.Encoder<E>
-
decode
public <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<Supplier<E>,T>> decode(com.mojang.serialization.DynamicOps<T> ops, T input)- Specified by:
decode
in interfacecom.mojang.serialization.Decoder<E>
-
toString
-