public class ByteBufUtils
extends java.lang.Object
ByteBuf
.Constructor and Description |
---|
ByteBufUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getContentDump(io.netty.buffer.ByteBuf buffer) |
static ItemStack |
readItemStack(io.netty.buffer.ByteBuf from)
Read an
ItemStack from the byte buffer provided. |
static NBTTagCompound |
readTag(io.netty.buffer.ByteBuf from)
Read an
NBTTagCompound from the byte buffer. |
static java.lang.String |
readUTF8String(io.netty.buffer.ByteBuf from)
Read a UTF8 string from the byte buffer.
|
static int |
readVarInt(io.netty.buffer.ByteBuf buf,
int maxSize)
Read a varint from the supplied buffer.
|
static int |
readVarShort(io.netty.buffer.ByteBuf buf)
An extended length short.
|
static int |
varIntByteCount(int toCount)
The number of bytes to write the supplied int using the 7 bit varint encoding.
|
static void |
writeItemStack(io.netty.buffer.ByteBuf to,
ItemStack stack)
Write an
ItemStack using minecraft compatible encoding. |
static void |
writeTag(io.netty.buffer.ByteBuf to,
NBTTagCompound tag)
Write an
NBTTagCompound to the byte buffer. |
static void |
writeUTF8String(io.netty.buffer.ByteBuf to,
java.lang.String string)
Write a String with UTF8 byte encoding to the buffer.
|
static void |
writeVarInt(io.netty.buffer.ByteBuf to,
int toWrite,
int maxSize)
Write an integer to the buffer using variable length encoding.
|
static void |
writeVarShort(io.netty.buffer.ByteBuf buf,
int toWrite) |
public static int varIntByteCount(int toCount)
toCount
- The number to analysepublic static int readVarInt(io.netty.buffer.ByteBuf buf, int maxSize)
buf
- The buffer to read frommaxSize
- The maximum length of bytes to readpublic static int readVarShort(io.netty.buffer.ByteBuf buf)
buf
- public static void writeVarShort(io.netty.buffer.ByteBuf buf, int toWrite)
public static void writeVarInt(io.netty.buffer.ByteBuf to, int toWrite, int maxSize)
to
- The buffer to write totoWrite
- The integer to writemaxSize
- The maximum number of bytes to usepublic static java.lang.String readUTF8String(io.netty.buffer.ByteBuf from)
from
- The buffer to read frompublic static void writeUTF8String(io.netty.buffer.ByteBuf to, java.lang.String string)
to
- the buffer to write tostring
- The string to writepublic static void writeItemStack(io.netty.buffer.ByteBuf to, ItemStack stack)
ItemStack
using minecraft compatible encoding.to
- The buffer to write tostack
- The itemstack to writepublic static ItemStack readItemStack(io.netty.buffer.ByteBuf from)
ItemStack
from the byte buffer provided. It uses the minecraft encoding.from
- The buffer to read frompublic static void writeTag(io.netty.buffer.ByteBuf to, NBTTagCompound tag)
NBTTagCompound
to the byte buffer. It uses the minecraft encoding.to
- The buffer to write totag
- The tag to writepublic static NBTTagCompound readTag(io.netty.buffer.ByteBuf from)
NBTTagCompound
from the byte buffer. It uses the minecraft encoding.from
- The buffer to read frompublic static java.lang.String getContentDump(io.netty.buffer.ByteBuf buffer)