Class PacketByteBufs

java.lang.Object
net.fabricmc.fabric.api.networking.v1.PacketByteBufs

public final class PacketByteBufs extends Object
Helper methods for working with and creating PacketByteBufs.
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(io.netty.buffer.ByteBuf buf)
    Wraps the newly created buf from buf.copy in a packet byte buf.
    copy(io.netty.buffer.ByteBuf buf, int index, int length)
    Wraps the newly created buf from buf.copy in a packet byte buf.
    Returns a new heap memory-backed instance of packet byte buf.
    duplicate(io.netty.buffer.ByteBuf buf)
    Wraps the newly created buf from buf.duplicate in a packet byte buf.
    Returns an empty instance of packet byte buf.
    readBytes(io.netty.buffer.ByteBuf buf, int length)
    Wraps the newly created buf from buf.readBytes in a packet byte buf.
    readRetainedSlice(io.netty.buffer.ByteBuf buf, int length)
    Wraps the newly created buf from buf.readRetainedSlice in a packet byte buf.
    readSlice(io.netty.buffer.ByteBuf buf, int length)
    Wraps the newly created buf from buf.readSlice in a packet byte buf.
    retainedDuplicate(io.netty.buffer.ByteBuf buf)
    Wraps the newly created buf from buf.retainedDuplicate in a packet byte buf.
    retainedSlice(io.netty.buffer.ByteBuf buf)
    Wraps the newly created buf from buf.retainedSlice in a packet byte buf.
    retainedSlice(io.netty.buffer.ByteBuf buf, int index, int length)
    Wraps the newly created buf from buf.retainedSlice in a packet byte buf.
    slice(io.netty.buffer.ByteBuf buf)
    Wraps the newly created buf from buf.slice in a packet byte buf.
    slice(io.netty.buffer.ByteBuf buf, int index, int length)
    Wraps the newly created buf from buf.slice in a packet byte buf.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • empty

      public static PacketByteBuf empty()
      Returns an empty instance of packet byte buf.
      Returns:
      an empty buf
    • create

      public static PacketByteBuf create()
      Returns a new heap memory-backed instance of packet byte buf.
      Returns:
      a new buf
    • readBytes

      public static PacketByteBuf readBytes(io.netty.buffer.ByteBuf buf, int length)
      Wraps the newly created buf from buf.readBytes in a packet byte buf.
      Parameters:
      buf - the original buf
      length - the number of bytes to transfer
      Returns:
      the transferred bytes
      See Also:
      • ByteBuf.readBytes(int)
    • readSlice

      public static PacketByteBuf readSlice(io.netty.buffer.ByteBuf buf, int length)
      Wraps the newly created buf from buf.readSlice in a packet byte buf.
      Parameters:
      buf - the original buf
      length - the size of the new slice
      Returns:
      the newly created slice
      See Also:
      • ByteBuf.readSlice(int)
    • readRetainedSlice

      public static PacketByteBuf readRetainedSlice(io.netty.buffer.ByteBuf buf, int length)
      Wraps the newly created buf from buf.readRetainedSlice in a packet byte buf.
      Parameters:
      buf - the original buf
      length - the size of the new slice
      Returns:
      the newly created slice
      See Also:
      • ByteBuf.readRetainedSlice(int)
    • copy

      public static PacketByteBuf copy(io.netty.buffer.ByteBuf buf)
      Wraps the newly created buf from buf.copy in a packet byte buf.
      Parameters:
      buf - the original buf
      Returns:
      a copy of the buf
      See Also:
      • ByteBuf.copy()
    • copy

      public static PacketByteBuf copy(io.netty.buffer.ByteBuf buf, int index, int length)
      Wraps the newly created buf from buf.copy in a packet byte buf.
      Parameters:
      buf - the original buf
      index - the starting index
      length - the size of the copy
      Returns:
      a copy of the buf
      See Also:
      • ByteBuf.copy(int, int)
    • slice

      public static PacketByteBuf slice(io.netty.buffer.ByteBuf buf)
      Wraps the newly created buf from buf.slice in a packet byte buf.
      Parameters:
      buf - the original buf
      Returns:
      a slice of the buf
      See Also:
      • ByteBuf.slice()
    • retainedSlice

      public static PacketByteBuf retainedSlice(io.netty.buffer.ByteBuf buf)
      Wraps the newly created buf from buf.retainedSlice in a packet byte buf.
      Parameters:
      buf - the original buf
      Returns:
      a slice of the buf
      See Also:
      • ByteBuf.retainedSlice()
    • slice

      public static PacketByteBuf slice(io.netty.buffer.ByteBuf buf, int index, int length)
      Wraps the newly created buf from buf.slice in a packet byte buf.
      Parameters:
      buf - the original buf
      index - the starting index
      length - the size of the copy
      Returns:
      a slice of the buf
      See Also:
      • ByteBuf.slice(int, int)
    • retainedSlice

      public static PacketByteBuf retainedSlice(io.netty.buffer.ByteBuf buf, int index, int length)
      Wraps the newly created buf from buf.retainedSlice in a packet byte buf.
      Parameters:
      buf - the original buf
      index - the starting index
      length - the size of the copy
      Returns:
      a slice of the buf
      See Also:
      • ByteBuf.retainedSlice(int, int)
    • duplicate

      public static PacketByteBuf duplicate(io.netty.buffer.ByteBuf buf)
      Wraps the newly created buf from buf.duplicate in a packet byte buf.
      Parameters:
      buf - the original buf
      Returns:
      a duplicate of the buf
      See Also:
      • ByteBuf.duplicate()
    • retainedDuplicate

      public static PacketByteBuf retainedDuplicate(io.netty.buffer.ByteBuf buf)
      Wraps the newly created buf from buf.retainedDuplicate in a packet byte buf.
      Parameters:
      buf - the original buf
      Returns:
      a duplicate of the buf
      See Also:
      • ByteBuf.retainedDuplicate()