Class NetByteBuf

java.lang.Object
io.netty.buffer.ByteBuf
net.minecraft.network.PacketByteBuf
alexiil.mc.lib.net.NetByteBuf
All Implemented Interfaces:
io.netty.util.ReferenceCounted, java.lang.Comparable<io.netty.buffer.ByteBuf>
Direct Known Subclasses:
CheckingNetByteBuf

public class NetByteBuf
extends net.minecraft.network.PacketByteBuf
Special PacketByteBuf class that provides methods specific to "offset" reading and writing - like writing a single bit to the stream, and auto-compacting it with similar bits into a single byte.

In addition this overrides a number of existing methods (like writeBoolean(boolean), writeEnumConstant(Enum), writeVarInt(int), writeVarLong(long)

  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  NetByteBuf.SavedReaderIndex  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static NetByteBuf EMPTY_BUFFER  
    static int MAX_VAR_S_INT_1_BYTE  
    static int MAX_VAR_S_INT_2_BYTES  
    static int MAX_VAR_S_INT_3_BYTES  
    static int MAX_VAR_S_INT_4_BYTES  
    static int MAX_VAR_U_INT_1_BYTE  
    static int MAX_VAR_U_INT_2_BYTES  
    static int MAX_VAR_U_INT_3_BYTES  
    static int MAX_VAR_U_INT_4_BYTES  
    static int MIN_VAR_S_INT_1_BYTE  
    static int MIN_VAR_S_INT_2_BYTES  
    static int MIN_VAR_S_INT_3_BYTES  
    static int MIN_VAR_S_INT_4_BYTES  
    static int MIN_VAR_U_INT_SMALL  
  • Constructor Summary

    Constructors 
    Constructor Description
    NetByteBuf​(io.netty.buffer.ByteBuf wrapped)  
  • Method Summary

    Modifier and Type Method Description
    static NetByteBuf asNetByteBuf​(io.netty.buffer.ByteBuf buf)
    Returns the given ByteBuf as NetByteBuf.
    static NetByteBuf buffer()  
    static NetByteBuf buffer​(int initialCapacity)  
    NetByteBuf clear()  
    NetByteBuf copy()  
    boolean isRecordingMarkers()  
    NetByteBuf markReaderIndex()  
    net.minecraft.util.math.BlockPos readBlockPos()
    Reads a BlockPos using 3 readVarInt()s rather than BlockPos.fromLong(long).
    boolean readBoolean()
    Reads a single boolean from some position in this buffer.
    NetByteBuf readBytes​(int length)  
    <E extends java.lang.Enum<E>>
    E
    readEnumConstant​(java.lang.Class<E> enumClass)  
    int readFixedBits​(int length)  
    net.minecraft.util.Identifier readIdentifier()
    Deprecated.
    Because PacketByteBuf.readIdentifier() can throw an InvalidIdentifierException, but
    net.minecraft.util.Identifier readIdentifierOrNull()
    Like readIdentifierSafe(), but returns null instead of throwing an error if the read string was invalid.
    net.minecraft.util.Identifier readIdentifierSafe()
    Reads in a string, and tries to parse it as an Identifier.
    void readMarker​(java.lang.String id)
    Reads a "marker" for debug purposes.
    java.lang.String readString()
    Reads a string of up to Short.MAX_VALUE length.
    int readVarInt()
    Reads out an integer using a variable number of bytes, assuming it was written by writeVarInt(int)
    long readVarLong()  
    int readVarUnsignedInt()
    Exposes the vanilla method for reading an unsigned integer using a variable number of bytes.
    long readVarUnsignedLong()
    Exposes the vanilla method for reading an unsigned long integer using a variable number of bytes.
    NetByteBuf resetReaderIndex()  
    NetByteBuf resetReaderIndex​(NetByteBuf.SavedReaderIndex index)  
    NetByteBuf.SavedReaderIndex saveReaderIndex()  
    NetByteBuf writeBlockPos​(net.minecraft.util.math.BlockPos pos)
    Writes out a BlockPos using 3 writeVarInt(int)s rather than BlockPos.asLong().
    NetByteBuf writeBoolean​(boolean flag)
    Writes a single boolean out to some position in this buffer.
    NetByteBuf writeEnumConstant​(java.lang.Enum<?> value)  
    NetByteBuf writeFixedBits​(int value, int length)
    Writes a fixed number of bits out to the stream.
    NetByteBuf writeIdentifier​(net.minecraft.util.Identifier id)  
    void writeMarker​(java.lang.String id)
    Writes a "marker" for debug purposes.
    NetByteBuf writeVarInt​(int ival)
    Writes out an integer using a variable number of bytes.
    NetByteBuf writeVarLong​(long lval)
    Writes out a long integer using a variable number of bytes.
    NetByteBuf writeVarUnsignedInt​(int ival)
    Exposes the vanilla method for writing out an unsigned integer using a variable number of bytes.
    NetByteBuf writeVarUnsignedLong​(long lval)
    Exposes the vanilla method for writing out an unsigned long integer using a variable number of bytes.

    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, 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, getVarIntSizeBytes, hasArray, hashCode, hasMemoryAddress, indexOf, internalNioBuffer, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, markWriterIndex, maxCapacity, maxWritableBytes, memoryAddress, method_30616, method_30617, nioBuffer, nioBuffer, nioBufferCount, nioBuffers, nioBuffers, order, order, readableBytes, readBlockHitResult, readByte, readByteArray, readByteArray, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readCharSequence, readChunkSectionPos, readCompoundTag, readDate, readDouble, readerIndex, readerIndex, readFloat, readInt, readIntArray, readIntArray, readIntLE, readItemStack, readLong, readLongArray, readLongArray, readLongLE, readMedium, readMediumLE, readRetainedSlice, readShort, readShortLE, readSlice, readString, readText, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, 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, writeBlockHitResult, writeByte, writeByteArray, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeCharSequence, writeCompoundTag, writeDate, writeDouble, writeFloat, writeInt, writeIntArray, writeIntLE, writeItemStack, writeLong, writeLongArray, writeLongLE, writeMedium, writeMediumLE, writerIndex, writerIndex, writeShort, writeShortLE, writeString, writeString, writeText, writeUuid, writeZero

    Methods inherited from class io.netty.buffer.ByteBuf

    getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait