Interface IFriendlyByteBufExtension

All Known Implementing Classes:
FriendlyByteBuf

public interface IFriendlyByteBufExtension
Additional helper methods for FriendlyByteBuf.
  • Method Details

    • self

      private FriendlyByteBuf self()
    • writeFluidStack

      default void writeFluidStack(FluidStack stack)
      Writes a FluidStack to the packet buffer, easy enough. If EMPTY, writes a FALSE. This behavior provides parity with the ItemStack method in PacketBuffer.
      Parameters:
      stack - FluidStack to be written to the packet buffer.
    • readFluidStack

      default FluidStack readFluidStack()
      Reads a FluidStack from this buffer.
    • writeObjectCollection

      default <T> void writeObjectCollection(Collection<T> set, BiConsumer<T,FriendlyByteBuf> writer)
      Writes the entries in the given set to the buffer, by first writing the count and then writing each entry.
      Type Parameters:
      T - The type of the entry
      Parameters:
      set - The set to write
      writer - The writer to use for writing each entry
      Implementation Note:
      This is a convenience method for FriendlyByteBuf.writeCollection(Collection, FriendlyByteBuf.Writer), where the callback can be a method on the entry type.
    • readItemWithLargeCount

      default ItemStack readItemWithLargeCount()
      Reads an ItemStack from the current buffer, but allows for a larger count than the vanilla method, using a variable length int instead of a byte.
      Returns:
      The read stack
    • writeItemWithLargeCount

      default FriendlyByteBuf writeItemWithLargeCount(ItemStack stack)
      Writes an ItemStack to the current buffer, but allows for a larger count than the vanilla method, using a variable length int instead of a byte.
      Parameters:
      stack - The stack to write
      Returns:
      The buffer
    • readArray

      default <T> T[] readArray(IntFunction<T[]> builder, FriendlyByteBuf.Reader<T> reader)
      Reads an array of objects from the buffer.
      Type Parameters:
      T - The type of the objects
      Parameters:
      builder - A function that creates an array of the given size
      reader - A function that reads an object from the buffer
      Returns:
      The array of objects
    • writeArray

      default <T> FriendlyByteBuf writeArray(T[] array, FriendlyByteBuf.Writer<T> writer)
      Writes an array of objects to the buffer.
      Type Parameters:
      T - The type of the objects
      Parameters:
      array - The array of objects
      writer - A function that writes an object to the buffer
      Returns:
      The buffer
    • writeByte

      default FriendlyByteBuf writeByte(byte value)
      Writes a byte to the buffer
      Parameters:
      value - The value to be written
      Returns:
      The buffer
    • readMap

      default <K, V> Map<K,V> readMap(FriendlyByteBuf.Reader<K> keyReader, BiFunction<FriendlyByteBuf,K,V> valueReader)
      Variant of FriendlyByteBuf.readMap(FriendlyByteBuf.Reader, FriendlyByteBuf.Reader) that allows reading values that depend on the key.
    • writeMap

      default <K, V> void writeMap(Map<K,V> map, FriendlyByteBuf.Writer<K> keyWriter, org.apache.commons.lang3.function.TriConsumer<FriendlyByteBuf,K,V> valueWriter)
      Variant of FriendlyByteBuf.writeMap(Map, FriendlyByteBuf.Writer, FriendlyByteBuf.Writer) that allows writing values that depend on the key.