public async void SerializeAsync(Stream stream) { var length = (uint)data.Count + packetId.SizeofBytes(); using (var bw = new NetworkWrite(stream, Encoding.UTF8, true)) { bw.WriteVarInt(length); bw.WriteVarInt(packetId); bw.Flush(); } await stream.WriteAsync(data.Array, data.Offset, data.Count); }