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 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(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:
    • readSlice

      public static PacketByteBuf readSlice(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:
    • readRetainedSlice

      public static PacketByteBuf readRetainedSlice(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:
    • copy

      public static PacketByteBuf copy(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:
    • copy

      public static PacketByteBuf copy(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:
    • slice

      public static PacketByteBuf slice(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:
    • retainedSlice

      public static PacketByteBuf retainedSlice(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:
    • slice

      public static PacketByteBuf slice(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:
    • retainedSlice

      public static PacketByteBuf retainedSlice(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:
    • duplicate

      public static PacketByteBuf duplicate(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:
    • retainedDuplicate

      public static PacketByteBuf retainedDuplicate(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: