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
Nested ClassesModifier and TypeClassDescriptionstatic final classUnchecked exception that's thrown when one of the types doesn't match.static enumA 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_SMALLFields inherited from class net.minecraft.network.PacketByteBuf
DEFAULT_MAX_STRING_LENGTH, MAX_TEXT_LENGTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintBit version ofPacketByteBuf.readerIndex().intBit version ofPacketByteBuf.writerIndex().intintbooleanbooleannet.minecraft.util.hit.BlockHitResultnet.minecraft.util.math.BlockPosbooleanReads a single boolean from some position in this buffer.bytereadByte()final CheckingNetByteBufreadBytes(byte[] dst) readBytes(byte[] dst, int dstIndex, int length) final CheckingNetByteBufreadBytes(io.netty.buffer.ByteBuf byteBuf) readBytes(io.netty.buffer.ByteBuf byteBuf, int length) charreadChar()doubledouble<E extends Enum<E>>
EreadEnumConstant(Class<E> enumClass) intreadFixedBits(int length) floatfloatintreadInt()intlongreadLong()longvoidreadMarker(String id) Reads a "marker" for debug purposes.voidreadMarkerId(int expected) voidreadMarkerId(IMsgReadCtx ctx, TreeNetIdBase netId) intintnet.minecraft.nbt.NbtCompoundreadNbt()shortshortReads a string of up toShort.MAX_VALUElength.readString(int maxLength) shortlonglongintintintintintReads out an integer using a variable number of bytes, assuming it was written byNetByteBuf.writeVarInt(int)longintExposes the vanilla method for reading an unsigned integer using a variable number of bytes.longExposes the vanilla method for reading an unsigned long integer using a variable number of bytes.voidCall this to make this use the typeData buffer to store the types read rather than written.voidwriteBlockHitResult(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) final CheckingNetByteBufwriteBytes(byte[] src) writeBytes(byte[] src, int srcIndex, int length) final CheckingNetByteBufwriteBytes(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) voidwriteMarker(String id) Writes a "marker" for debug purposes.voidwriteMarkerId(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, writeIdentifierMethods 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, getMaxValidator, 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, readOptional, 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, writeOptional, writerIndex, writerIndex, writeText, writeUuid, writeZeroMethods inherited from class io.netty.buffer.ByteBuf
getDoubleLE, getFloatLE, isContiguous, maxFastWritableBytes, 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:NetByteBufBit version ofPacketByteBuf.writerIndex().- Overrides:
getBitWriterIndexin classNetByteBuf
-
getBitReaderIndex
public int getBitReaderIndex()Description copied from class:NetByteBufBit version ofPacketByteBuf.readerIndex().- Overrides:
getBitReaderIndexin 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:NetByteBufReads 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:
readBooleanin classNetByteBuf
-
writeBoolean
Description copied from class:NetByteBufWrites 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:
writeBooleanin classNetByteBuf
-
readByte
public byte readByte()- Overrides:
readBytein classnet.minecraft.network.PacketByteBuf
-
readUnsignedByte
public short readUnsignedByte()- Overrides:
readUnsignedBytein classnet.minecraft.network.PacketByteBuf
-
writeByte
- Overrides:
writeBytein classnet.minecraft.network.PacketByteBuf
-
readShort
public short readShort()- Overrides:
readShortin classnet.minecraft.network.PacketByteBuf
-
readUnsignedShort
public int readUnsignedShort()- Overrides:
readUnsignedShortin classnet.minecraft.network.PacketByteBuf
-
writeShort
- Overrides:
writeShortin classnet.minecraft.network.PacketByteBuf
-
readMedium
public int readMedium()- Overrides:
readMediumin classnet.minecraft.network.PacketByteBuf
-
readUnsignedMedium
public int readUnsignedMedium()- Overrides:
readUnsignedMediumin classnet.minecraft.network.PacketByteBuf
-
writeMedium
- Overrides:
writeMediumin classnet.minecraft.network.PacketByteBuf
-
readInt
public int readInt()- Overrides:
readIntin classnet.minecraft.network.PacketByteBuf
-
readUnsignedInt
public long readUnsignedInt()- Overrides:
readUnsignedIntin classnet.minecraft.network.PacketByteBuf
-
writeInt
- Overrides:
writeIntin classnet.minecraft.network.PacketByteBuf
-
readLong
public long readLong()- Overrides:
readLongin classnet.minecraft.network.PacketByteBuf
-
writeLong
- Overrides:
writeLongin classnet.minecraft.network.PacketByteBuf
-
readShortLE
public short readShortLE()- Overrides:
readShortLEin classnet.minecraft.network.PacketByteBuf
-
readUnsignedShortLE
public int readUnsignedShortLE()- Overrides:
readUnsignedShortLEin classnet.minecraft.network.PacketByteBuf
-
writeShortLE
- Overrides:
writeShortLEin classnet.minecraft.network.PacketByteBuf
-
readMediumLE
public int readMediumLE()- Overrides:
readMediumLEin classnet.minecraft.network.PacketByteBuf
-
readUnsignedMediumLE
public int readUnsignedMediumLE()- Overrides:
readUnsignedMediumLEin classnet.minecraft.network.PacketByteBuf
-
writeMediumLE
- Overrides:
writeMediumLEin classnet.minecraft.network.PacketByteBuf
-
readIntLE
public int readIntLE()- Overrides:
readIntLEin classnet.minecraft.network.PacketByteBuf
-
readUnsignedIntLE
public long readUnsignedIntLE()- Overrides:
readUnsignedIntLEin classnet.minecraft.network.PacketByteBuf
-
writeIntLE
- Overrides:
writeIntLEin classnet.minecraft.network.PacketByteBuf
-
readLongLE
public long readLongLE()- Overrides:
readLongLEin classnet.minecraft.network.PacketByteBuf
-
writeLongLE
- Overrides:
writeLongLEin classnet.minecraft.network.PacketByteBuf
-
readFloat
public float readFloat()- Overrides:
readFloatin classnet.minecraft.network.PacketByteBuf
-
writeFloat
- Overrides:
writeFloatin classnet.minecraft.network.PacketByteBuf
-
readFloatLE
public float readFloatLE()- Overrides:
readFloatLEin classio.netty.buffer.ByteBuf
-
writeFloatLE
- Overrides:
writeFloatLEin classio.netty.buffer.ByteBuf
-
readDouble
public double readDouble()- Overrides:
readDoublein classnet.minecraft.network.PacketByteBuf
-
writeDouble
- Overrides:
writeDoublein classnet.minecraft.network.PacketByteBuf
-
readDoubleLE
public double readDoubleLE()- Overrides:
readDoubleLEin classio.netty.buffer.ByteBuf
-
writeDoubleLE
- Overrides:
writeDoubleLEin classio.netty.buffer.ByteBuf
-
readChar
public char readChar()- Overrides:
readCharin classnet.minecraft.network.PacketByteBuf
-
writeChar
- Overrides:
writeCharin classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytesin classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytesin classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytesin classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytesin classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytesin classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytesin classnet.minecraft.network.PacketByteBuf
-
readBytes
- Overrides:
readBytesin classnet.minecraft.network.PacketByteBuf
-
writeBytes
- Overrides:
writeBytesin classnet.minecraft.network.PacketByteBuf
-
readBlockPos
public net.minecraft.util.math.BlockPos readBlockPos()Description copied from class:NetByteBuf- Overrides:
readBlockPosin classNetByteBuf
-
writeBlockPos
Description copied from class:NetByteBuf- Overrides:
writeBlockPosin classNetByteBuf
-
readBlockHitResult
public net.minecraft.util.hit.BlockHitResult readBlockHitResult()- Overrides:
readBlockHitResultin classnet.minecraft.network.PacketByteBuf
-
writeBlockHitResult
public void writeBlockHitResult(net.minecraft.util.hit.BlockHitResult blockHitResult) - Overrides:
writeBlockHitResultin classnet.minecraft.network.PacketByteBuf
-
readNbt
public net.minecraft.nbt.NbtCompound readNbt()- Overrides:
readNbtin classnet.minecraft.network.PacketByteBuf
-
writeNbt
- Overrides:
writeNbtin classnet.minecraft.network.PacketByteBuf
-
readString
Description copied from class:NetByteBufReads a string of up toShort.MAX_VALUElength.NOTE: This is just
PacketByteBuf.readString()but available on the server as well.- Overrides:
readStringin classNetByteBuf
-
writeString
- Overrides:
writeStringin classnet.minecraft.network.PacketByteBuf
-
readString
- Overrides:
readStringin classnet.minecraft.network.PacketByteBuf
-
writeString
- Overrides:
writeStringin classnet.minecraft.network.PacketByteBuf
-
readEnumConstant
- Overrides:
readEnumConstantin classNetByteBuf
-
writeEnumConstant
- Overrides:
writeEnumConstantin classNetByteBuf
-
readVarUnsignedInt
public int readVarUnsignedInt()Description copied from class:NetByteBufExposes 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:
readVarUnsignedIntin classNetByteBuf
-
writeVarUnsignedInt
Description copied from class:NetByteBufExposes the vanilla method for writing out an unsigned integer using a variable number of bytes.- 1 byte for
NetByteBuf.MIN_VAR_U_INT_SMALLtoNetByteBuf.MAX_VAR_S_INT_1_BYTE - 2 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALLtoNetByteBuf.MAX_VAR_S_INT_2_BYTES - 3 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALLtoNetByteBuf.MAX_VAR_S_INT_3_BYTES - 4 bytes for
NetByteBuf.MIN_VAR_U_INT_SMALLtoNetByteBuf.MAX_VAR_S_INT_4_BYTES - 5 bytes for
Integer.MIN_VALUEtoInteger.MAX_VALUE
Unlike
NetByteBuf.writeVarInt(int)this only uses less than 5 bytes for non-negative integers less thanpow(2, 8 * 3 - 1)()- Overrides:
writeVarUnsignedIntin classNetByteBuf
- 1 byte for
-
readVarUnsignedLong
public long readVarUnsignedLong()Description copied from class:NetByteBufExposes 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:
readVarUnsignedLongin classNetByteBuf
-
writeVarUnsignedLong
Description copied from class:NetByteBufExposes 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:
writeVarUnsignedLongin classNetByteBuf
-
readFixedBits
- Overrides:
readFixedBitsin 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:NetByteBufWrites a fixed number of bits out to the stream.- Overrides:
writeFixedBitsin 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:NetByteBufReads out an integer using a variable number of bytes, assuming it was written byNetByteBuf.writeVarInt(int)- Overrides:
readVarIntin classNetByteBuf
-
writeVarInt
Description copied from class:NetByteBufWrites out an integer using a variable number of bytes.- 1 byte for
NetByteBuf.MIN_VAR_S_INT_1_BYTEtoNetByteBuf.MAX_VAR_S_INT_1_BYTE - 2 bytes for
NetByteBuf.MIN_VAR_S_INT_2_BYTEStoNetByteBuf.MAX_VAR_S_INT_2_BYTES - 3 bytes for
NetByteBuf.MIN_VAR_S_INT_3_BYTEStoNetByteBuf.MAX_VAR_S_INT_3_BYTES - 4 bytes for
NetByteBuf.MIN_VAR_S_INT_4_BYTEStoNetByteBuf.MAX_VAR_S_INT_4_BYTES - 5 bytes for
Integer.MIN_VALUEtoInteger.MAX_VALUE
Unlike vanilla this doesn't use 5 bytes for all negative numbers.
- Overrides:
writeVarIntin classNetByteBuf
- 1 byte for
-
readVarLong
public long readVarLong()- Overrides:
readVarLongin classNetByteBuf
-
writeVarLong
Description copied from class:NetByteBufWrites 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:
writeVarLongin classNetByteBuf
-
isRecordingMarkers
public boolean isRecordingMarkers()- Overrides:
isRecordingMarkersin classNetByteBuf- Returns:
- True if
NetByteBuf.writeMarker(String)actually does anything.
-
readMarker
Description copied from class:NetByteBufReads 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:
readMarkerin classNetByteBuf- Throws:
InvalidInputDataException
-
writeMarker
Description copied from class:NetByteBufWrites a "marker" for debug purposes. If debugging is disabled then this won't do anything.- Overrides:
writeMarkerin classNetByteBuf
-