Package net.minecraft.resources
Class RegistryFileCodec<E>
java.lang.Object
net.minecraft.resources.RegistryFileCodec<E>
- All Implemented Interfaces:
com.mojang.serialization.Codec<Holder<E>>
,com.mojang.serialization.Decoder<Holder<E>>
,com.mojang.serialization.Encoder<Holder<E>>
public final class RegistryFileCodec<E>
extends Object
implements com.mojang.serialization.Codec<Holder<E>>
A codec that wraps a single element, or "file", within a registry. Possibly allows inline definitions, and always falls back to the element codec (and thus writing the registry element inline) if it fails to decode from the registry.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mojang.serialization.Codec
com.mojang.serialization.Codec.RecursiveCodec<T>, com.mojang.serialization.Codec.ResultFunction<A>
Nested classes/interfaces inherited from interface com.mojang.serialization.Decoder
com.mojang.serialization.Decoder.Boxed<A>, com.mojang.serialization.Decoder.Simple<A>, com.mojang.serialization.Decoder.Terminal<A>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final com.mojang.serialization.Codec
<E> private final ResourceKey
<? 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
ConstructorsModifierConstructorDescriptionprivate
RegistryFileCodec
(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec, boolean pAllowInline) -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> RegistryFileCodec
<E> create
(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec) Creates a codec for a single registry element, which is held as an un-resolvedSupplier<E>
.static <E> RegistryFileCodec
<E> create
(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec, boolean pAllowInline) decode
(com.mojang.serialization.DynamicOps<T> pOps, T pInput) <T> com.mojang.serialization.DataResult
<T> 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, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, listOf, listOf, mapResult, optionalFieldOf, optionalFieldOf, optionalFieldOf, optionalFieldOf, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, partialDispatch, promotePartial, sizeLimitedListOf, stable, validate, 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
-
registryKey
-
elementCodec
-
allowInline
private final boolean allowInline
-
-
Constructor Details
-
RegistryFileCodec
private RegistryFileCodec(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec, boolean pAllowInline)
-
-
Method Details
-
create
public static <E> RegistryFileCodec<E> create(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec) Creates a codec for a single registry element, which is held as an un-resolvedSupplier<E>
. Both inline definitions of the object, and references to an existing registry element id are allowed.- Parameters:
pRegistryKey
- The registry which elements may belong to.pElementCodec
- The codec used to decode either inline definitions, or elements before entering them into the registry.
-
create
public static <E> RegistryFileCodec<E> create(ResourceKey<? extends Registry<E>> pRegistryKey, com.mojang.serialization.Codec<E> pElementCodec, boolean pAllowInline) -
encode
public <T> com.mojang.serialization.DataResult<T> encode(Holder<E> pInput, com.mojang.serialization.DynamicOps<T> pOps, T pPrefix) - Specified by:
encode
in interfacecom.mojang.serialization.Encoder<E>
-
decode
public <T> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<Holder<E>,T>> decode(com.mojang.serialization.DynamicOps<T> pOps, T pInput) - Specified by:
decode
in interfacecom.mojang.serialization.Decoder<E>
-
toString
-