Interface IFriendlyByteBufExtension
- All Known Implementing Classes:
FriendlyByteBuf
,RegistryFriendlyByteBuf
public interface IFriendlyByteBufExtension
Additional helper methods for
FriendlyByteBuf
.-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T[]
readArray
(IntFunction<T[]> builder, StreamDecoder<? super FriendlyByteBuf, T> reader) Reads an array of objects from the buffer.default <K,
V> Map <K, V> readMap
(StreamDecoder<? super FriendlyByteBuf, K> keyReader, BiFunction<FriendlyByteBuf, K, V> valueReader) Variant ofFriendlyByteBuf.readMap(StreamDecoder, StreamDecoder)
that allows reading values that depend on the key.private FriendlyByteBuf
self()
default <T> FriendlyByteBuf
writeArray
(T[] array, StreamEncoder<? super FriendlyByteBuf, T> writer) Writes an array of objects to the buffer.default FriendlyByteBuf
writeByte
(byte value) Writes a byte to the bufferdefault <K,
V> void writeMap
(Map<K, V> map, StreamEncoder<? super FriendlyByteBuf, K> keyWriter, org.apache.commons.lang3.function.TriConsumer<FriendlyByteBuf, K, V> valueWriter) Variant ofFriendlyByteBuf.writeMap(Map, StreamEncoder, StreamEncoder)
that allows writing values that depend on the key.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.
-
Method Details
-
self
-
writeObjectCollection
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 writewriter
- The writer to use for writing each entry
-
readArray
default <T> T[] readArray(IntFunction<T[]> builder, StreamDecoder<? super FriendlyByteBuf, 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 sizereader
- A function that reads an object from the buffer- Returns:
- The array of objects
-
writeArray
Writes an array of objects to the buffer.- Type Parameters:
T
- The type of the objects- Parameters:
array
- The array of objectswriter
- A function that writes an object to the buffer- Returns:
- The buffer
-
writeByte
Writes a byte to the buffer- Parameters:
value
- The value to be written- Returns:
- The buffer
-
readMap
default <K,V> Map<K,V> readMap(StreamDecoder<? super FriendlyByteBuf, K> keyReader, BiFunction<FriendlyByteBuf, K, V> valueReader) Variant ofFriendlyByteBuf.readMap(StreamDecoder, StreamDecoder)
that allows reading values that depend on the key. -
writeMap
default <K,V> void writeMap(Map<K, V> map, StreamEncoder<? super FriendlyByteBuf, K> keyWriter, org.apache.commons.lang3.function.TriConsumer<FriendlyByteBuf, K, V> valueWriter) Variant ofFriendlyByteBuf.writeMap(Map, StreamEncoder, StreamEncoder)
that allows writing values that depend on the key.
-