Package org.moddingx.libx.codec
Class CodecOps<E>
java.lang.Object
org.moddingx.libx.codec.CodecOps<E>
Provides some utility methods to encode and decode thing using a codec for a
specific
DynamicOps
.
CodecOps
for json
and nbt
can be found in CodecHelper
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
Reads a value using a codec.<T> T
read
(com.mojang.serialization.Codec<T> codec, E value, net.minecraft.core.HolderLookup.Provider registries) Reads a value using a codec.<T> E
write
(com.mojang.serialization.Codec<T> codec, T value) Writes an element using a code.<T,
R extends E>
RWrites an element using a code.<T,
R extends E>
Rwrite
(com.mojang.serialization.Codec<T> codec, T value, Class<R> resultType, net.minecraft.core.HolderLookup.Provider registries) Writes an element using a code.<T> E
write
(com.mojang.serialization.Codec<T> codec, T value, net.minecraft.core.HolderLookup.Provider registries) Writes an element using a code.
-
Constructor Details
-
CodecOps
Creates newCodecOps
.- Parameters:
baseClass
- The base value class of theDynamicOps
to use.ops
- The baseDynamicOps
to use.
-
-
Method Details
-
write
Writes an element using a code. -
write
public <T> E write(com.mojang.serialization.Codec<T> codec, T value, net.minecraft.core.HolderLookup.Provider registries) Writes an element using a code.- Parameters:
registries
- TheRegistryAccess
to provide for registry aware codecs.
-
write
public <T,R extends E> R write(com.mojang.serialization.Codec<T> codec, T value, Class<R> resultType) Writes an element using a code.- Parameters:
resultType
- The class that the result is expected to have. It is ensured, that the result is of this class. If the codec produces data of another class, an exception will be thrown.
-
write
public <T,R extends E> R write(com.mojang.serialization.Codec<T> codec, T value, Class<R> resultType, net.minecraft.core.HolderLookup.Provider registries) Writes an element using a code.- Parameters:
resultType
- The class that the result is expected to have. It is ensured, that the result is of this class. If the codec produces data of another class, an exception will be thrown.registries
- TheRegistryAccess
to provide for registry aware codecs.
-
read
Reads a value using a codec. -
read
public <T> T read(com.mojang.serialization.Codec<T> codec, E value, net.minecraft.core.HolderLookup.Provider registries) Reads a value using a codec.- Parameters:
registries
- TheRegistryAccess
to provide for registry aware codecs.
-