Package alexiil.mc.lib.net
Class CheckingNetByteBuf
java.lang.Object
io.netty.buffer.ByteBuf
net.minecraft.network.PacketByteBuf
alexiil.mc.lib.net.NetByteBuf
alexiil.mc.lib.net.CheckingNetByteBuf
- All Implemented Interfaces:
io.netty.util.ReferenceCounted
,Comparable<io.netty.buffer.ByteBuf>
Debug variant of
NetByteBuf
that writes the method calls to ensure that it's a perfect mirror. This uses a
separate data buffer for reading & writing types, which can be null if no type data is present.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Unchecked exception that's thrown when one of the types doesn't match.static class
A networking related method that wrote data to the buffer.Nested classes/interfaces inherited from class alexiil.mc.lib.net.NetByteBuf
NetByteBuf.SavedReaderIndex
-
Field Summary
Fields inherited from class alexiil.mc.lib.net.NetByteBuf
EMPTY_BUFFER, MAX_VAR_S_INT_1_BYTE, MAX_VAR_S_INT_2_BYTES, MAX_VAR_S_INT_3_BYTES, MAX_VAR_S_INT_4_BYTES, MAX_VAR_U_INT_1_BYTE, MAX_VAR_U_INT_2_BYTES, MAX_VAR_U_INT_3_BYTES, MAX_VAR_U_INT_4_BYTES, MIN_VAR_S_INT_1_BYTE, MIN_VAR_S_INT_2_BYTES, MIN_VAR_S_INT_3_BYTES, MIN_VAR_S_INT_4_BYTES, MIN_VAR_U_INT_SMALL
Fields inherited from class net.minecraft.network.PacketByteBuf
DEFAULT_MAX_STRING_LENGTH, MAX_TEXT_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Bit version ofPacketByteBuf.readerIndex()
.int
Bit version ofPacketByteBuf.writerIndex()
.int
int
boolean
boolean
net.minecraft.util.hit.BlockHitResult
net.minecraft.util.math.BlockPos
boolean
Reads a single boolean from some position in this buffer.byte
readByte()
readBytes(byte[] dst)
readBytes(byte[] dst, int dstIndex, int length)
readBytes(io.netty.buffer.ByteBuf byteBuf)
readBytes(io.netty.buffer.ByteBuf byteBuf, int length)
char
readChar()
double
double
<E extends Enum<E>>
EreadEnumConstant(Class<E> enumClass)
int
readFixedBits(int length)
float
float
int
readInt()
int
long
readLong()
long
void
readMarker(String id)
Reads a "marker" for debug purposes.void
readMarkerId(int expected)
void
readMarkerId(IMsgReadCtx ctx, TreeNetIdBase netId)
int
int
net.minecraft.nbt.NbtCompound
readNbt()
short
short
Reads a string of up toShort.MAX_VALUE
length.readString(int maxLength)
short
long
long
int
int
int
int
int
Reads out an integer using a variable number of bytes, assuming it was written byNetByteBuf.writeVarInt(int)
long
int
Exposes the vanilla method for reading an unsigned integer using a variable number of bytes.long
Exposes the vanilla method for reading an unsigned long integer using a variable number of bytes.void
Call this to make this use the typeData buffer to store the types read rather than written.void
writeBlockHitResult(net.minecraft.util.hit.BlockHitResult blockHitResult)
writeBlockPos(net.minecraft.util.math.BlockPos pos)
writeBoolean(boolean flag)
Writes a single boolean out to some position in this buffer.writeByte(int i)
writeBytes(byte[] src)
writeBytes(byte[] src, int srcIndex, int length)
writeBytes(io.netty.buffer.ByteBuf byteBuf)
writeBytes(io.netty.buffer.ByteBuf byteBuf, int length)
writeChar(int i)
writeDouble(double d)
writeDoubleLE(double value)
writeEnumConstant(Enum<?> value)
writeFixedBits(int value, int length)
Writes a fixed number of bits out to the stream.writeFloat(float f)
writeFloatLE(float value)
writeInt(int i)
writeIntLE(int i)
writeLong(long l)
writeLongLE(long l)
void
writeMarker(String id)
Writes a "marker" for debug purposes.void
writeMarkerId(int id)
writeMedium(int i)
writeMediumLE(int i)
writeNbt(net.minecraft.nbt.NbtCompound compoundTag)
writeShort(int i)
writeShortLE(int i)
writeString(String string)
writeString(String string, int maxLength)
writeVarInt(int ival)
Writes out an integer using a variable number of bytes.writeVarLong(long lval)
Writes out a long integer using a variable number of bytes.writeVarUnsignedInt(int ival)
Exposes the vanilla method for writing out an unsigned integer using a variable number of bytes.writeVarUnsignedLong(long lval)
Exposes the vanilla method for writing out an unsigned long integer using a variable number of bytes.Methods inherited from class alexiil.mc.lib.net.NetByteBuf
asNetByteBuf, buffer, buffer, clear, copy, markReaderIndex, readBytes, readIdentifier, readIdentifierOrNull, readIdentifierSafe, resetReaderIndex, resetReaderIndex, saveReaderIndex, writeIdentifier
Methods inherited from class net.minecraft.network.PacketByteBuf
alloc, array, arrayOffset, asReadOnly, bytesBefore, bytesBefore, bytesBefore, capacity, capacity, compareTo, copy, decode, discardReadBytes, discardSomeReadBytes, duplicate, encode, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, forEachInCollection, getBoolean, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, getVarIntLength, getVarLongLength, getWrittenBytes, hasArray, hashCode, hasMemoryAddress, indexOf, internalNioBuffer, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, markWriterIndex, maxCapacity, maxWritableBytes, memoryAddress, nioBuffer, nioBuffer, nioBufferCount, nioBuffers, nioBuffers, order, order, readableBytes, readBitSet, readByteArray, readByteArray, readBytes, readBytes, readBytes, readBytes, readBytes, readCharSequence, readChunkPos, readChunkSectionPos, readCollection, readDate, readerIndex, readerIndex, readIntArray, readIntArray, readIntList, readItemStack, readList, readLongArray, readLongArray, readLongArray, readMap, readMap, readNbt, readRetainedSlice, readSlice, readText, readUnlimitedNbt, readUuid, refCnt, release, release, resetWriterIndex, retain, retain, retainedDuplicate, retainedSlice, retainedSlice, setBoolean, setByte, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, slice, slice, toString, toString, toString, touch, touch, unwrap, writableBytes, writeBitSet, writeByteArray, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeCharSequence, writeChunkPos, writeChunkSectionPos, writeCollection, writeDate, writeIntArray, writeIntList, writeItemStack, writeLongArray, writeMap, writerIndex, writerIndex, writeText, writeUuid, writeZero
Methods inherited from class io.netty.buffer.ByteBuf
getDoubleLE, getFloatLE, setDoubleLE, setFloatLE
-
Constructor Details
-
CheckingNetByteBuf
-
-
Method Details
-
recordReads
public void recordReads()Call this to make this use the typeData buffer to store the types read rather than written. Useful only if the type data wasn't provided by the writer. -
getCountRead
public int getCountRead()- Returns:
- The number of read calls made.
-
getCountWrite
public int getCountWrite()- Returns:
- The number of write calls made.
-
getBitWriterIndex
public int getBitWriterIndex()Description copied from class:NetByteBuf
Bit version ofPacketByteBuf.writerIndex()
.- Overrides:
getBitWriterIndex
in classNetByteBuf
-
getBitReaderIndex
public int getBitReaderIndex()Description copied from class:NetByteBuf
Bit version ofPacketByteBuf.readerIndex()
.- Overrides:
getBitReaderIndex
in classNetByteBuf
-
readMarkerId
public void readMarkerId(int expected) -
readMarkerId
-
writeMarkerId
public void writeMarkerId(int id) -
hasTypeData
public boolean hasTypeData() -
readBoolean
public boolean readBoolean()Description copied from class:NetByteBuf
Reads a single boolean from some position in this buffer. The boolean flag might be read from a new byte (increasing the readerIndex) or it might be read from a previous byte that was read with a previous call to this method.- Overrides:
readBoolean
in classNetByteBuf
-
writeBoolean
Description copied from class:NetByteBuf
Writes a single boolean out to some position in this buffer. The boolean flag might be written to a new byte (increasing the writerIndex) or it might be added to an existing byte that was written with a previous call to this method.- Overrides:
writeBoolean
in classNetByteBuf
-
readByte
public byte readByte()- Overrides:
readByte
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedByte
public short readUnsignedByte()- Overrides:
readUnsignedByte
in classnet.minecraft.network.PacketByteBuf
-
writeByte
- Overrides:
writeByte
in classnet.minecraft.network.PacketByteBuf
-
readShort
public short readShort()- Overrides:
readShort
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedShort
public int readUnsignedShort()- Overrides:
readUnsignedShort
in classnet.minecraft.network.PacketByteBuf
-
writeShort
- Overrides:
writeShort
in classnet.minecraft.network.PacketByteBuf
-
readMedium
public int readMedium()- Overrides:
readMedium
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedMedium
public int readUnsignedMedium()- Overrides:
readUnsignedMedium
in classnet.minecraft.network.PacketByteBuf
-
writeMedium
- Overrides:
writeMedium
in classnet.minecraft.network.PacketByteBuf
-
readInt
public int readInt()- Overrides:
readInt
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedInt
public long readUnsignedInt()- Overrides:
readUnsignedInt
in classnet.minecraft.network.PacketByteBuf
-
writeInt
- Overrides:
writeInt
in classnet.minecraft.network.PacketByteBuf
-
readLong
public long readLong()- Overrides:
readLong
in classnet.minecraft.network.PacketByteBuf
-
writeLong
- Overrides:
writeLong
in classnet.minecraft.network.PacketByteBuf
-
readShortLE
public short readShortLE()- Overrides:
readShortLE
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedShortLE
public int readUnsignedShortLE()- Overrides:
readUnsignedShortLE
in classnet.minecraft.network.PacketByteBuf
-
writeShortLE
- Overrides:
writeShortLE
in classnet.minecraft.network.PacketByteBuf
-
readMediumLE
public int readMediumLE()- Overrides:
readMediumLE
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedMediumLE
public int readUnsignedMediumLE()- Overrides:
readUnsignedMediumLE
in classnet.minecraft.network.PacketByteBuf
-
writeMediumLE
- Overrides:
writeMediumLE
in classnet.minecraft.network.PacketByteBuf
-
readIntLE
public int readIntLE()- Overrides:
readIntLE
in classnet.minecraft.network.PacketByteBuf
-
readUnsignedIntLE
public long readUnsignedIntLE()- Overrides:
readUnsignedIntLE
in classnet.minecraft.network.PacketByteBuf
-
writeIntLE
- Overrides:
writeIntLE
in classnet.minecraft.network.PacketByteBuf
-
readLongLE
public long readLongLE()- Overrides:
readLongLE
in classnet.minecraft.network.PacketByteBuf
-
writeLongLE
- Overrides:
writeLongLE
in classnet.minecraft.network.PacketByteBuf
-
readFloat
public float readFloat()- Overrides:
readFloat
in classnet.minecraft.network.PacketByteBuf
-
writeFloat
- Overrides:
writeFloat
in classnet.minecraft.network.PacketByteBuf
-
readFloatLE
public float readFloatLE()- Overrides:
readFloatLE
in classio.netty.buffer.ByteBuf
-
writeFloatLE
- Overrides:
writeFloatLE
in classio.netty.buffer.ByteBuf
-
readDouble
public double readDouble()- Overrides:
readDouble
in classnet.minecraft.network.PacketByteBuf
-
writeDouble
- Overrides:
writeDouble
in classnet.minecraft.network.PacketByteBuf
-
readDoubleLE
public double readDoubleLE()- Overrides:
readDoubleLE
in classio.netty.buffer.ByteBuf
-
writeDoubleLE
- Overrides:
writeDoubleLE
in classio.netty.buffer.ByteBuf
-
readChar
public char readChar()- Overrides:
readChar
in classnet.minecraft.network.PacketByteBuf
-
writeChar
- Overrides:
writeChar
in classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytes
in classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytes
in classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytes
in classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytes
in classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytes
in classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytes
in classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytes
in classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytes
in classnet.minecraft.network.PacketByteBuf
-
readBlockPos
public net.minecraft.util.math.BlockPos readBlockPos()Description copied from class:NetByteBuf
- Overrides:
readBlockPos
in classNetByteBuf
-
writeBlockPos
Description copied from class:NetByteBuf
- Overrides:
writeBlockPos
in classNetByteBuf
-
readBlockHitResult
public net.minecraft.util.hit.BlockHitResult readBlockHitResult()- Overrides:
readBlockHitResult
in classnet.minecraft.network.PacketByteBuf
-
writeBlockHitResult
public void writeBlockHitResult(net.minecraft.util.hit.BlockHitResult blockHitResult)- Overrides:
writeBlockHitResult
in classnet.minecraft.network.PacketByteBuf
-
readNbt
public net.minecraft.nbt.NbtCompound readNbt()- Overrides:
readNbt
in classnet.minecraft.network.PacketByteBuf
-
writeNbt
- Overrides:
writeNbt
in classnet.minecraft.network.PacketByteBuf
-
readString
Description copied from class:NetByteBuf
Reads a string of up toShort.MAX_VALUE
length.NOTE: This is just
PacketByteBuf.readString()
but available on the server as well.- Overrides:
readString
in classNetByteBuf
-
writeString
- Overrides:
writeString
in classnet.minecraft.network.PacketByteBuf
-
readString
- Overrides:
readString
in classnet.minecraft.network.PacketByteBuf
-
writeString
- Overrides:
writeString
in classnet.minecraft.network.PacketByteBuf
-
readEnumConstant
- Overrides:
readEnumConstant
in classNetByteBuf
-
writeEnumConstant
- Overrides:
writeEnumConstant
in classNetByteBuf
-
readVarUnsignedInt
public int readVarUnsignedInt()Description copied from class:NetByteBuf
Exposes the vanilla method for reading an unsigned integer using a variable number of bytes.Unlike
NetByteBuf.readVarInt()
this only uses less than 5 bytes for non-negative integers less thanpow(2, 8 * 3 - 1)
()- Overrides:
readVarUnsignedInt
in classNetByteBuf
-
writeVarUnsignedInt
Description copied from class:NetByteBuf
Exposes the vanilla method for writing out an unsigned integer using a variable number of bytes.- 1 byte for
NetByteBuf.MIN_VAR_U_INT_SMALL
toNetByteBuf.MAX_VAR_S_INT_1_BYTE
- 2 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALL
toNetByteBuf.MAX_VAR_S_INT_2_BYTES
- 3 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALL
toNetByteBuf.MAX_VAR_S_INT_3_BYTES
- 4 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALL
toNetByteBuf.MAX_VAR_S_INT_4_BYTES
- 5 bytes for
Integer.MIN_VALUE
toInteger.MAX_VALUE
Unlike
NetByteBuf.writeVarInt(int)
this only uses less than 5 bytes for non-negative integers less thanpow(2, 8 * 3 - 1)
()- Overrides:
writeVarUnsignedInt
in classNetByteBuf
- 1 byte for
-
readVarUnsignedLong
public long readVarUnsignedLong()Description copied from class:NetByteBuf
Exposes the vanilla method for reading an unsigned long integer using a variable number of bytes.Unlike
NetByteBuf.readVarInt()
this only uses less than 9 bytes for non-negative integers less thanpow(2, 8 * 7 - 1)
()- Overrides:
readVarUnsignedLong
in classNetByteBuf
-
writeVarUnsignedLong
Description copied from class:NetByteBuf
Exposes the vanilla method for writing out an unsigned long integer using a variable number of bytes.Unlike
NetByteBuf.writeVarInt(int)
this only uses less than 9 bytes for non-negative integers less thanpow(2, 8 * 7 - 1)
()- Overrides:
writeVarUnsignedLong
in classNetByteBuf
-
readFixedBits
- Overrides:
readFixedBits
in classNetByteBuf
- Parameters:
length
- The number of bits to read.- Returns:
- The read bits, compacted into an int.
- Throws:
IllegalArgumentException
- if the length argument was less than 1 or greater than 32.
-
writeFixedBits
Description copied from class:NetByteBuf
Writes a fixed number of bits out to the stream.- Overrides:
writeFixedBits
in classNetByteBuf
- Parameters:
value
- the value to write out.length
- The number of bits to write.- Returns:
- This buffer.
- Throws:
IllegalArgumentException
- if the length argument was less than 1 or greater than 32.
-
readVarInt
public int readVarInt()Description copied from class:NetByteBuf
Reads out an integer using a variable number of bytes, assuming it was written byNetByteBuf.writeVarInt(int)
- Overrides:
readVarInt
in classNetByteBuf
-
writeVarInt
Description copied from class:NetByteBuf
Writes out an integer using a variable number of bytes.- 1 byte for
NetByteBuf.MIN_VAR_S_INT_1_BYTE
toNetByteBuf.MAX_VAR_S_INT_1_BYTE
- 2 bytes for
NetByteBuf.MIN_VAR_S_INT_2_BYTES
toNetByteBuf.MAX_VAR_S_INT_2_BYTES
- 3 bytes for
NetByteBuf.MIN_VAR_S_INT_3_BYTES
toNetByteBuf.MAX_VAR_S_INT_3_BYTES
- 4 bytes for
NetByteBuf.MIN_VAR_S_INT_4_BYTES
toNetByteBuf.MAX_VAR_S_INT_4_BYTES
- 5 bytes for
Integer.MIN_VALUE
toInteger.MAX_VALUE
Unlike vanilla this doesn't use 5 bytes for all negative numbers.
- Overrides:
writeVarInt
in classNetByteBuf
- 1 byte for
-
readVarLong
public long readVarLong()- Overrides:
readVarLong
in classNetByteBuf
-
writeVarLong
Description copied from class:NetByteBuf
Writes out a long integer using a variable number of bytes.- 1 byte for -64 to 63
- 2 bytes for -8,192 to 8,191
- 3 bytes for -1,048,576 to 1,048,575
- 4 bytes for -134,217,728 to 134,217,727
Unlike vanilla this doesn't use 9 bytes for all negative numbers.
- Overrides:
writeVarLong
in classNetByteBuf
-
isRecordingMarkers
public boolean isRecordingMarkers()- Overrides:
isRecordingMarkers
in classNetByteBuf
- Returns:
- True if
NetByteBuf.writeMarker(String)
actually does anything.
-
readMarker
Description copied from class:NetByteBuf
Reads a "marker" for debug purposes. If debugging is disabled then this won't do anything. Otherwise this will throw an exception if the marker ID's didn't match.- Overrides:
readMarker
in classNetByteBuf
- Throws:
InvalidInputDataException
-
writeMarker
Description copied from class:NetByteBuf
Writes a "marker" for debug purposes. If debugging is disabled then this won't do anything.- Overrides:
writeMarker
in classNetByteBuf
-