Class Type<T>

java.lang.Object
com.viaversion.viaversion.api.type.Type<T>
Type Parameters:
T - read/written type
All Implemented Interfaces:
ByteBufReader<T>, ByteBufWriter<T>
Direct Known Subclasses:
ArrayType, BitSetType, BlockChangeRecordType, BlockEntityType1_18, BlockEntityType1_20_2, BlockPositionType1_14, BlockPositionType1_8, BooleanType, BulkChunkType1_8, ByteArrayType, ByteType, ChunkPositionType, ChunkSectionType1_13, ChunkSectionType1_16, ChunkSectionType1_18, ChunkSectionType1_8, ChunkSectionType1_9, ChunkType1_13, ChunkType1_14, ChunkType1_15, ChunkType1_16, ChunkType1_16_2, ChunkType1_17, ChunkType1_18, ChunkType1_20_2, ChunkType1_8, ChunkType1_9_1, ChunkType1_9_3, ComponentType, CompoundTagType, DoubleType, DynamicType, EmptyType, EntityDataListTypeTemplate, EntityDataTypeTemplate, EulerAngleType, Filterable.FilterableType, FixedByteArrayType, FloatType, GameProfileType, GlobalBlockPositionType, HolderSetType, HolderType, IntArrayType, IntType, ItemCostType1_20_5, ItemShortArrayType1_13, ItemShortArrayType1_13_2, ItemShortArrayType1_8, ItemType1_13, ItemType1_13_2, ItemType1_20_2, ItemType1_20_5, ItemType1_8, LongArrayType, LongType, NamedCompoundTagType, OptionalType, OptionalVarIntType, PaletteType1_18, PlayerMessageSignatureType, ProfileKeyType, QuaternionType, RegistryEntryType, RemainingBytesType, ShortByteArrayType, ShortType, StringType, StructuredDataType, TagType, UnsignedByteType, UnsignedShortType, UUIDType, VarIntArrayType, VarIntType, VarLongBlockChangeRecordType, VarLongType, Vector3fType, VectorType, VillagerDataType

public abstract class Type<T> extends Object implements ByteBufReader<T>, ByteBufWriter<T>
Type for buffer reading and writing.
See Also:
  • Constructor Details

    • Type

      protected Type(Class<? super T> outputClass)
    • Type

      protected Type(String typeName, Class<? super T> outputClass)
  • Method Details

    • getOutputClass

      public Class<? super T> getOutputClass()
      Returns the output class type.
      Returns:
      output class type
    • getTypeName

      public String getTypeName()
      Returns the type name.
      Returns:
      type name
    • getBaseClass

      public Class<? extends Type> getBaseClass()
      Returns the base class, useful when the output class is insufficient for type comparison. One such case are types with {List} as their output type.
      Returns:
      base class
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • readEither

      public static <X, Y> Either<X,Y> readEither(io.netty.buffer.ByteBuf buf, Type<X> leftType, Type<Y> rightType)
    • writeEither

      public static <X, Y> void writeEither(io.netty.buffer.ByteBuf buf, Either<X,Y> value, Type<X> leftType, Type<Y> rightType)