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 <T extends IForgeRegistryEntry<T>> |
readRegistryEntries(io.netty.buffer.ByteBuf in,
IForgeRegistry<T> registry)
Read multiple registry entries from the same registries from the stream.
|
static <T extends IForgeRegistryEntry<T>> |
readRegistryEntry(io.netty.buffer.ByteBuf in,
IForgeRegistry<T> registry)
Read a registry entry from the stream.
|
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 <T extends IForgeRegistryEntry<T>> |
writeRegistryEntries(io.netty.buffer.ByteBuf out,
java.util.Collection<T> entries)
Write multiple registry entries from the same registry to the stream.
|
static <T extends IForgeRegistryEntry<T>> |
writeRegistryEntry(io.netty.buffer.ByteBuf out,
T entry)
Write a registry entry to the stream.
|
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 write@Nullable public 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 <T extends IForgeRegistryEntry<T>> void writeRegistryEntry(@Nonnull io.netty.buffer.ByteBuf out, @Nonnull T entry)
out
- the buffer to write toentry
- the registry entry@Nonnull public static <T extends IForgeRegistryEntry<T>> T readRegistryEntry(@Nonnull io.netty.buffer.ByteBuf in, @Nonnull IForgeRegistry<T> registry)
writeRegistryEntry(ByteBuf, IForgeRegistryEntry)
is used.in
- the buffer to read fromregistry
- the registry the entry belongs topublic static <T extends IForgeRegistryEntry<T>> void writeRegistryEntries(@Nonnull io.netty.buffer.ByteBuf out, @Nonnull java.util.Collection<T> entries)
writeRegistryEntry(ByteBuf, IForgeRegistryEntry)
multiple times.out
- the buffer to write toentries
- the entries to write@Nonnull public static <T extends IForgeRegistryEntry<T>> java.util.List<T> readRegistryEntries(@Nonnull io.netty.buffer.ByteBuf in, @Nonnull IForgeRegistry<T> registry)
writeRegistryEntries(ByteBuf, Collection)
.in
- the buffer to read fromregistry
- the registry the entries belong topublic static java.lang.String getContentDump(io.netty.buffer.ByteBuf buffer)