Class CodecUtil

java.lang.Object
com.minecolonies.api.util.CodecUtil

public class CodecUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<net.minecraft.world.level.ChunkPos>
    Chunk pos codec
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CHUNK_POS

      public static final com.mojang.serialization.Codec<net.minecraft.world.level.ChunkPos> CHUNK_POS
      Chunk 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 codec
      logger - logger for errors
      instanceIfErrored - 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 codec
      logger - logger for errors
      instanceIfErrored - 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