Package codechicken.lib.data
Interface MCDataInput
- All Known Implementing Classes:
MCDataByteBuf,MCDataInputStream,PacketCustom
public interface MCDataInput
Provides the ability to read various datas from some sort of data stream.
See
MCDataInputStream to wrap an InputStream to this.
See MCByteStream to wrap an ByteBuf to this.
Created by covers1624 on 4/15/20.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleanReads a boolean from the stream.default boolean[]Reads a block of booleans written with,MCDataOutput.writeBooleans(boolean[]), orMCDataOutput.writeBooleans(boolean[], int, int)bytereadByte()Reads a byte from the stream.default io.netty.buffer.ByteBufReads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int),MCDataOutput.writeByteBuffer(ByteBuffer), orMCDataOutput.writeByteBuf(ByteBuf)default ByteBufferReads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int),MCDataOutput.writeByteBuffer(ByteBuffer), orMCDataOutput.writeByteBuf(ByteBuf)default byte[]Reads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int), orMCDataOutput.writeByteBuffer(ByteBuffer)charreadChar()Reads a char from the stream.default CharBufferReads a block of chars written with,MCDataOutput.writeChars(char[]),MCDataOutput.writeChars(char[], int, int), orMCDataOutput.writeCharBuffer(CharBuffer)default char[]Reads a block of chars written with,MCDataOutput.writeChars(char[]),MCDataOutput.writeChars(char[], int, int), orMCDataOutput.writeCharBuffer(CharBuffer)default net.minecraft.nbt.CompoundTagReads aCompoundTagfrom the stream.default Cuboid6Reads aCuboid6from the stream.default net.minecraft.core.DirectionReads aDirectionfrom the stream.doubleReads a double from the stream.default DoubleBufferReads a block of doubles written with,MCDataOutput.writeDoubles(double[]),MCDataOutput.writeDoubles(double[], int, int), orMCDataOutput.writeDoubleBuffer(DoubleBuffer).default double[]Reads a block of doubles written with,MCDataOutput.writeDoubles(double[]),MCDataOutput.writeDoubles(double[], int, int), orMCDataOutput.writeDoubleBuffer(DoubleBuffer).default <T extends Enum<T>>
TReads anEnumvalue from the stream.floatReads a float from the stream.default FloatBufferReads a block of floats written with,MCDataOutput.writeFloats(float[]),MCDataOutput.writeFloats(float[], int, int), orMCDataOutput.writeFloatBuffer(FloatBuffer).default float[]Reads a block of floats written with,MCDataOutput.writeFloats(float[]),MCDataOutput.writeFloats(float[], int, int), orMCDataOutput.writeFloatBuffer(FloatBuffer).default net.minecraftforge.fluids.FluidStackReads aFluidStackfrom the stream.intreadInt()Reads an int from the stream.default IntBufferReads a block of ints written with,MCDataOutput.writeInts(int[]),MCDataOutput.writeInts(int[], int, int), orMCDataOutput.writeIntBuffer(IntBuffer).default int[]readInts()Reads a block of ints written with,MCDataOutput.writeInts(int[]),MCDataOutput.writeInts(int[], int, int), orMCDataOutput.writeIntBuffer(IntBuffer).default net.minecraft.world.item.ItemStackReads anItemStackfrom the stream.longreadLong()Reads a long from the stream.default LongBufferReads a block of longs written with,MCDataOutput.writeLongs(long[]),MCDataOutput.writeLongs(long[], int, int), orMCDataOutput.writeLongBuffer(LongBuffer).default long[]Reads a block of longs written with,MCDataOutput.writeLongs(long[]),MCDataOutput.writeLongs(long[], int, int), orMCDataOutput.writeLongBuffer(LongBuffer).default net.minecraft.core.BlockPosreadPos()Reads aBlockPosfrom the stream.default <T> TReads a registry object from the stream.default <T> TreadRegistryIdDirect(net.minecraftforge.registries.IForgeRegistry<T> registry) Reads a registry object from the stream.default net.minecraft.resources.ResourceLocationReads aResourceLocationfrom the stream.shortReads a Short from the stream.default ShortBufferReads a block of shorts written with,MCDataOutput.writeShorts(short[]),MCDataOutput.writeShorts(short[], int, int), orMCDataOutput.writeShortBuffer(ShortBuffer).default short[]Reads a block of shorts written with,MCDataOutput.writeShorts(short[]),MCDataOutput.writeShorts(short[], int, int), orMCDataOutput.writeShortBuffer(ShortBuffer).default intReads a Variable length signed int.default int[]Reads an array of Variable length Signed ints from the stream.default longReads a Variable length signed long.default long[]Reads an array of Variable length Signed longs from the stream.default StringReads a UTF-8 encodedStringfrom the stream.default net.minecraft.network.chat.MutableComponentReads anComponentfrom the stream.shortReads an Unsigned byte from the stream.intReads an Unsigned short from the stream.default UUIDreadUUID()Reads aUUIDfrom the stream.default intReads a Variable length int from the stream.default int[]Reads an array of Variable length ints from the stream.default longReads a Variable length long from the stream.default long[]Reads an array of Variable length longs from the stream.default net.minecraft.world.phys.Vec3Reads aVec3from the stream.default org.joml.Vector3fReads aVector3ffrom the stream.default net.minecraft.core.Vec3iReads aVec3ifrom the stream.default Vector3Reads aVector3from the stream.default DataInputWraps this stream into aDataInputstream.default InputStreamWraps this stream into anInputStream.
-
Method Details
-
readByte
byte readByte()Reads a byte from the stream.- Returns:
- The byte.
-
readUByte
short readUByte()Reads an Unsigned byte from the stream.- Returns:
- The Unsigned byte.
-
readChar
char readChar()Reads a char from the stream.- Returns:
- The char.
-
readShort
short readShort()Reads a Short from the stream.- Returns:
- The short.
-
readUShort
int readUShort()Reads an Unsigned short from the stream.- Returns:
- The Unsigned short.
-
readInt
int readInt()Reads an int from the stream.- Returns:
- The int.
-
readLong
long readLong()Reads a long from the stream.- Returns:
- The long.
-
readFloat
float readFloat()Reads a float from the stream.- Returns:
- The float.
-
readDouble
double readDouble()Reads a double from the stream.- Returns:
- The double.
-
readBoolean
boolean readBoolean()Reads a boolean from the stream.- Returns:
- The boolean.
-
readBytes
default byte[] readBytes()Reads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int), orMCDataOutput.writeByteBuffer(ByteBuffer)- Returns:
- The bytes.
-
readChars
default char[] readChars()Reads a block of chars written with,MCDataOutput.writeChars(char[]),MCDataOutput.writeChars(char[], int, int), orMCDataOutput.writeCharBuffer(CharBuffer)- Returns:
- The chars.
-
readShorts
default short[] readShorts()Reads a block of shorts written with,MCDataOutput.writeShorts(short[]),MCDataOutput.writeShorts(short[], int, int), orMCDataOutput.writeShortBuffer(ShortBuffer).- Returns:
- The shorts.
-
readInts
default int[] readInts()Reads a block of ints written with,MCDataOutput.writeInts(int[]),MCDataOutput.writeInts(int[], int, int), orMCDataOutput.writeIntBuffer(IntBuffer).- Returns:
- The ints.
-
readLongs
default long[] readLongs()Reads a block of longs written with,MCDataOutput.writeLongs(long[]),MCDataOutput.writeLongs(long[], int, int), orMCDataOutput.writeLongBuffer(LongBuffer).- Returns:
- The longs.
-
readFloats
default float[] readFloats()Reads a block of floats written with,MCDataOutput.writeFloats(float[]),MCDataOutput.writeFloats(float[], int, int), orMCDataOutput.writeFloatBuffer(FloatBuffer).- Returns:
- The floats.
-
readDoubles
default double[] readDoubles()Reads a block of doubles written with,MCDataOutput.writeDoubles(double[]),MCDataOutput.writeDoubles(double[], int, int), orMCDataOutput.writeDoubleBuffer(DoubleBuffer).- Returns:
- The doubles.
-
readBooleans
default boolean[] readBooleans()Reads a block of booleans written with,MCDataOutput.writeBooleans(boolean[]), orMCDataOutput.writeBooleans(boolean[], int, int)- Returns:
- The booleans.
-
readVarInt
default int readVarInt()Reads a Variable length int from the stream.- Returns:
- The int.
-
readVarLong
default long readVarLong()Reads a Variable length long from the stream.- Returns:
- The long.
-
readSignedVarInt
default int readSignedVarInt()Reads a Variable length signed int.- Returns:
- The int.
- See Also:
-
readSignedVarLong
default long readSignedVarLong()Reads a Variable length signed long.- Returns:
- The long.
- See Also:
-
readVarInts
default int[] readVarInts()Reads an array of Variable length ints from the stream.- Returns:
- The ints.
-
readVarLongs
default long[] readVarLongs()Reads an array of Variable length longs from the stream.- Returns:
- The longs.
-
readSignedVarInts
default int[] readSignedVarInts()Reads an array of Variable length Signed ints from the stream.- Returns:
- The ints.
-
readSignedVarLongs
default long[] readSignedVarLongs()Reads an array of Variable length Signed longs from the stream.- Returns:
- The longs.
-
readString
Reads a UTF-8 encodedStringfrom the stream.- Returns:
- The
String.
-
readUUID
Reads aUUIDfrom the stream.- Returns:
- The
UUID.
-
readEnum
Reads anEnumvalue from the stream.- Parameters:
clazz- The Class of the enum.- Returns:
- The
Enumvalue.
-
readByteBuffer
Reads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int),MCDataOutput.writeByteBuffer(ByteBuffer), orMCDataOutput.writeByteBuf(ByteBuf)- Returns:
- The bytes.
-
readCharBuffer
Reads a block of chars written with,MCDataOutput.writeChars(char[]),MCDataOutput.writeChars(char[], int, int), orMCDataOutput.writeCharBuffer(CharBuffer)- Returns:
- The chars.
-
readShortBuffer
Reads a block of shorts written with,MCDataOutput.writeShorts(short[]),MCDataOutput.writeShorts(short[], int, int), orMCDataOutput.writeShortBuffer(ShortBuffer).- Returns:
- The shorts.
-
readIntBuffer
Reads a block of ints written with,MCDataOutput.writeInts(int[]),MCDataOutput.writeInts(int[], int, int), orMCDataOutput.writeIntBuffer(IntBuffer).- Returns:
- The ints.
-
readLongBuffer
Reads a block of longs written with,MCDataOutput.writeLongs(long[]),MCDataOutput.writeLongs(long[], int, int), orMCDataOutput.writeLongBuffer(LongBuffer).- Returns:
- The longs.
-
readFloatBuffer
Reads a block of floats written with,MCDataOutput.writeFloats(float[]),MCDataOutput.writeFloats(float[], int, int), orMCDataOutput.writeFloatBuffer(FloatBuffer).- Returns:
- The floats.
-
readDoubleBuffer
Reads a block of doubles written with,MCDataOutput.writeDoubles(double[]),MCDataOutput.writeDoubles(double[], int, int), orMCDataOutput.writeDoubleBuffer(DoubleBuffer).- Returns:
- The doubles.
-
readVector
Reads aVector3from the stream.- Returns:
- The
Vector3.
-
readCuboid
Reads aCuboid6from the stream.- Returns:
- The
Cuboid6.
-
readResourceLocation
default net.minecraft.resources.ResourceLocation readResourceLocation()Reads aResourceLocationfrom the stream.- Returns:
- The
ResourceLocation.
-
readDirection
default net.minecraft.core.Direction readDirection()Reads aDirectionfrom the stream.- Returns:
- The
Direction.
-
readPos
default net.minecraft.core.BlockPos readPos()Reads aBlockPosfrom the stream.- Returns:
- The
BlockPos.
-
readVec3i
default net.minecraft.core.Vec3i readVec3i()Reads aVec3ifrom the stream.- Returns:
- The
Vec3i.
-
readVec3d
default net.minecraft.world.phys.Vec3 readVec3d()Reads aVec3from the stream.- Returns:
- The
Vec3.
-
readVec3f
default org.joml.Vector3f readVec3f()Reads aVector3ffrom the stream.- Returns:
- The
Vector3f.
-
readCompoundNBT
@Nullable default net.minecraft.nbt.CompoundTag readCompoundNBT()Reads aCompoundTagfrom the stream.- Returns:
- The
CompoundTag.
-
readItemStack
default net.minecraft.world.item.ItemStack readItemStack()Reads anItemStackfrom the stream. It should also be noted that this implementation reads theItemStack.getCount()as a varInt opposed to a byte, as that is favourable in some cases.- Returns:
- The
ItemStack.
-
readFluidStack
default net.minecraftforge.fluids.FluidStack readFluidStack()Reads aFluidStackfrom the stream.- Returns:
- The
FluidStack.
-
readTextComponent
default net.minecraft.network.chat.MutableComponent readTextComponent()Reads anComponentfrom the stream.- Returns:
- The
Component.
-
readRegistryIdDirect
default <T> T readRegistryIdDirect(net.minecraftforge.registries.IForgeRegistry<T> registry) Reads a registry object from the stream.- Parameters:
registry- TheIForgeRegistryto load the entry from.- Returns:
- The registry object..
- See Also:
-
readRegistryId
default <T> T readRegistryId()Reads a registry object from the stream.- Returns:
- The registry object.
- See Also:
-
readByteBuf
default io.netty.buffer.ByteBuf readByteBuf()Reads a block of bytes written with,MCDataOutput.writeBytes(byte[]),MCDataOutput.writeBytes(byte[], int, int),MCDataOutput.writeByteBuffer(ByteBuffer), orMCDataOutput.writeByteBuf(ByteBuf)- Returns:
- The bytes.
-
toDataInput
Wraps this stream into aDataInputstream. any data read from the returnedDataInputis read from this stream.- Returns:
- The
DataInput.
-
toInputStream
Wraps this stream into anInputStream. any data read from the returnedInputStreamis read from this stream.- Returns:
- The
InputStream.
-