Class ValueTransformer<T1,​T2>

  • All Implemented Interfaces:
    ValueWriter<T1>

    public abstract class ValueTransformer<T1,​T2>
    extends java.lang.Object
    implements ValueWriter<T1>
    • Constructor Detail

      • ValueTransformer

        protected ValueTransformer​(@Nullable Type<T1> inputType,
                                   Type<T2> outputType)
      • ValueTransformer

        protected ValueTransformer​(Type<T2> outputType)
    • Method Detail

      • transform

        public abstract T2 transform​(PacketWrapper wrapper,
                                     T1 inputValue)
                              throws java.lang.Exception
        Transform a value from one type to another
        Parameters:
        wrapper - The current packet
        inputValue - The input value
        Returns:
        The value to write to the wrapper
        Throws:
        java.lang.Exception - Throws exception if it fails to transform a value
      • write

        public void write​(PacketWrapper writer,
                          T1 inputValue)
                   throws java.lang.Exception
        Description copied from interface: ValueWriter
        Write a value to a packet
        Specified by:
        write in interface ValueWriter<T1>
        Parameters:
        writer - The packet wrapper to write to
        inputValue - The value to write
        Throws:
        java.lang.Exception - Throws exception if it fails to write
      • getInputType

        public @Nullable Type<T1> getInputType()
      • getOutputType

        public Type<T2> getOutputType()