Package com.minecolonies.api.util
Class CodecUtil
java.lang.Object
com.minecolonies.api.util.CodecUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<net.minecraft.world.level.ChunkPos> Chunk pos codec -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Function<net.minecraft.nbt.CompoundTag, T> nbtDecoder(com.mojang.serialization.Codec<T> codec, org.slf4j.Logger logger, Supplier<T> instanceIfErrored) static <T> Function<T, net.minecraft.nbt.CompoundTag> nbtEncoder(com.mojang.serialization.Codec<T> codec, org.slf4j.Logger logger, Supplier<net.minecraft.nbt.CompoundTag> instanceIfErrored) static <T> com.mojang.serialization.Codec<Set<T>> set(com.mojang.serialization.Codec<T> codec, Function<Collection<T>, Set<T>> setFactory) Set codec, backed by list codec
-
Field Details
-
CHUNK_POS
public static final com.mojang.serialization.Codec<net.minecraft.world.level.ChunkPos> CHUNK_POSChunk pos codec
-
-
Method Details
-
nbtDecoder
public static <T> Function<net.minecraft.nbt.CompoundTag,T> nbtDecoder(com.mojang.serialization.Codec<T> codec, org.slf4j.Logger logger, Supplier<T> instanceIfErrored) - Parameters:
codec- type codeclogger- logger for errorsinstanceIfErrored- will be returned from function if error occurs- Returns:
- decoding function
-
nbtEncoder
public static <T> Function<T,net.minecraft.nbt.CompoundTag> nbtEncoder(com.mojang.serialization.Codec<T> codec, org.slf4j.Logger logger, Supplier<net.minecraft.nbt.CompoundTag> instanceIfErrored) - Parameters:
codec- type codeclogger- logger for errorsinstanceIfErrored- will be returned from function if error occurs- Returns:
- encoding function
-
set
public static <T> com.mojang.serialization.Codec<Set<T>> set(com.mojang.serialization.Codec<T> codec, Function<Collection<T>, Set<T>> setFactory) Set codec, backed by list codec
-