mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
parent
aaf1e8311b
commit
e1a041799b
19 changed files with 9599 additions and 0 deletions
34
DebugTools/MinecraftClientProxy/ZlibUtils.cs
Normal file
34
DebugTools/MinecraftClientProxy/ZlibUtils.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Ionic.Zlib;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
/// <summary>
|
||||
/// Quick Zlib compression handling for network packet compression.
|
||||
/// Note: Underlying compression handling is taken from the DotNetZip Library.
|
||||
/// This library is open source and provided under the Microsoft Public License.
|
||||
/// More info about DotNetZip at dotnetzip.codeplex.com.
|
||||
/// </summary>
|
||||
|
||||
public static class ZlibUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Decompress a byte array into another byte array of the specified size
|
||||
/// </summary>
|
||||
/// <param name="to_decompress">Data to decompress</param>
|
||||
/// <param name="size_uncompressed">Size of the data once decompressed</param>
|
||||
/// <returns>Decompressed data as a byte array</returns>
|
||||
|
||||
public static byte[] Decompress(byte[] to_decompress, int size_uncompressed)
|
||||
{
|
||||
ZlibStream stream = new ZlibStream(new System.IO.MemoryStream(to_decompress, false), CompressionMode.Decompress);
|
||||
byte[] packetData_decompressed = new byte[size_uncompressed];
|
||||
stream.Read(packetData_decompressed, 0, size_uncompressed);
|
||||
stream.Close();
|
||||
return packetData_decompressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue