Class CodecHelper

java.lang.Object
com.petrolpark.util.CodecHelper

public class CodecHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends io.netty.buffer.ByteBuf, S extends Enum<S>>
    net.minecraft.network.codec.StreamCodec<T,S>
    enumStream(Class<S> clazz)
     
    static <OBJECT> com.mojang.serialization.Codec<List<OBJECT>>
    listOrSingle(com.mojang.serialization.Codec<OBJECT> codec)
     
    static <B extends io.netty.buffer.ByteBuf, V>
    net.minecraft.network.codec.StreamCodec<B,List<V>>
    listStream(net.minecraft.network.codec.StreamCodec<B,V> base)
     
    static <OBJECT, FIELD>
    com.mojang.serialization.Codec<OBJECT>
    singleField(com.mojang.serialization.Codec<FIELD> fieldCodec, String fieldName, Function<OBJECT,FIELD> getter, Function<FIELD,OBJECT> constructor)
     
    static <OBJECT, FIELD>
    com.mojang.serialization.MapCodec<OBJECT>
    singleFieldMap(com.mojang.serialization.Codec<FIELD> fieldCodec, String fieldName, Function<OBJECT,FIELD> getter, Function<FIELD,OBJECT> constructor)
     

    Methods inherited from class java.lang.Object

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

    • CodecHelper

      public CodecHelper()
  • Method Details

    • singleField

      public static <OBJECT, FIELD> com.mojang.serialization.Codec<OBJECT> singleField(com.mojang.serialization.Codec<FIELD> fieldCodec, String fieldName, Function<OBJECT,FIELD> getter, Function<FIELD,OBJECT> constructor)
    • singleFieldMap

      public static <OBJECT, FIELD> com.mojang.serialization.MapCodec<OBJECT> singleFieldMap(com.mojang.serialization.Codec<FIELD> fieldCodec, String fieldName, Function<OBJECT,FIELD> getter, Function<FIELD,OBJECT> constructor)
    • listOrSingle

      public static <OBJECT> com.mojang.serialization.Codec<List<OBJECT>> listOrSingle(com.mojang.serialization.Codec<OBJECT> codec)
    • enumStream

      public static <T extends io.netty.buffer.ByteBuf, S extends Enum<S>> net.minecraft.network.codec.StreamCodec<T,S> enumStream(Class<S> clazz)
    • listStream

      public static <B extends io.netty.buffer.ByteBuf, V> net.minecraft.network.codec.StreamCodec<B,List<V>> listStream(net.minecraft.network.codec.StreamCodec<B,V> base)