cpw.mods.fml.common.network

## Class ByteBufUtils

- java.lang.Object
- - cpw.mods.fml.common.network.ByteBufUtils

-     public class ByteBufUtils
      extends java.lang.Object

  Utilities for interacting with `ByteBuf`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ByteBufUtils()`

  - ### Method Summary

    Methods
    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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ByteBufUtils

          public ByteBufUtils()

  - ### Method Detail

    - #### varIntByteCount

          public static int varIntByteCount(int toCount)

      The number of bytes to write the supplied int using the 7 bit varint encoding.
      Parameters:
        `toCount` - The number to analyse
      Returns:
        The number of bytes it will take to write it (maximum of 5)

    - #### readVarInt

          public static int readVarInt(io.netty.buffer.ByteBuf buf,
                       int maxSize)

      Read a varint from the supplied buffer.
      Parameters:
        `buf` - The buffer to read from
        `maxSize` - The maximum length of bytes to read
      Returns:
        The integer

    - #### readVarShort

          public static int readVarShort(io.netty.buffer.ByteBuf buf)

      An extended length short. Used by custom payload packets to extend size.
      Parameters:
        `buf` -
      Returns:

    - #### writeVarShort

          public static void writeVarShort(io.netty.buffer.ByteBuf buf,
                           int toWrite)

    - #### writeVarInt

          public static void writeVarInt(io.netty.buffer.ByteBuf to,
                         int toWrite,
                         int maxSize)

      Write an integer to the buffer using variable length encoding. The maxSize constrains how many bytes (and therefore the maximum number) that will be written.
      Parameters:
        `to` - The buffer to write to
        `toWrite` - The integer to write
        `maxSize` - The maximum number of bytes to use

    - #### readUTF8String

          public static java.lang.String readUTF8String(io.netty.buffer.ByteBuf from)

      Read a UTF8 string from the byte buffer. It is encoded as []
      Parameters:
        `from` - The buffer to read from
      Returns:
        The string

    - #### writeUTF8String

          public static void writeUTF8String(io.netty.buffer.ByteBuf to,
                             java.lang.String string)

      Write a String with UTF8 byte encoding to the buffer. It is encoded as []
      Parameters:
        `to` - the buffer to write to
        `string` - The string to write

    - #### writeItemStack

          public static void writeItemStack(io.netty.buffer.ByteBuf to,
                            ItemStack stack)

      Write an `ItemStack` using minecraft compatible encoding.
      Parameters:
        `to` - The buffer to write to
        `stack` - The itemstack to write

    - #### readItemStack

          public static ItemStack readItemStack(io.netty.buffer.ByteBuf from)

      Read an `ItemStack` from the byte buffer provided. It uses the minecraft encoding.
      Parameters:
        `from` - The buffer to read from
      Returns:
        The itemstack read

    - #### writeTag

          public static void writeTag(io.netty.buffer.ByteBuf to,
                      NBTTagCompound tag)

      Write an `NBTTagCompound` to the byte buffer. It uses the minecraft encoding.
      Parameters:
        `to` - The buffer to write to
        `tag` - The tag to write

    - #### readTag

          public static NBTTagCompound readTag(io.netty.buffer.ByteBuf from)

      Read an `NBTTagCompound` from the byte buffer. It uses the minecraft encoding.
      Parameters:
        `from` - The buffer to read from
      Returns:
        The read tag

    - #### getContentDump

          public static java.lang.String getContentDump(io.netty.buffer.ByteBuf buffer)