Add support for creating replay mod capture files (#1246)

* Add test replay handler
* Fix incorrect built raw packet
* Fix incorrect built raw packet
* Add filter
* Add not working zip lib
* Add dotNetZip lib and complete basic function
* Update ReplayHandler.cs
* Complete Replay handler
Without client player handling
* Complete replay mod
- New ChatBot OnNetworkPacket event
* Add auto-backup and command for Replay Mod
* Add ReplayMod description to readme
* Small naming changes, fix compile error on .NET4.0
* ReplayHandler slight optimizations
Use Path.Combine to automatically use Windows '\' or Linux '/'
Move re-usable common parts outside the Replay handler
Small optimizations in building JSON strings
Co-authored-by: ORelio <oreliogitantispam.l0gin@spamgourmet.com>
This commit is contained in:
ReinforceZwei 2020-09-07 03:51:42 +08:00 committed by GitHub
parent cd1badb9d6
commit 7e20e409a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 32732 additions and 21 deletions

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Protocol
{
public static class GuidExtensions
{
/// <summary>
/// A CLSCompliant method to convert a Java big-endian Guid to a .NET
/// little-endian Guid.
/// The Guid Constructor (UInt32, UInt16, UInt16, Byte, Byte, Byte, Byte,
/// Byte, Byte, Byte, Byte) is not CLSCompliant.
/// </summary>
public static Guid ToLittleEndian(this Guid javaGuid)
{
byte[] net = new byte[16];
byte[] java = javaGuid.ToByteArray();
for (int i = 8; i < 16; i++)
{
net[i] = java[i];
}
net[3] = java[0];
net[2] = java[1];
net[1] = java[2];
net[0] = java[3];
net[5] = java[4];
net[4] = java[5];
net[6] = java[7];
net[7] = java[6];
return new Guid(net);
}
/// <summary>
/// Converts little-endian .NET guids to big-endian Java guids:
/// </summary>
public static Guid ToBigEndian(this Guid netGuid)
{
byte[] java = new byte[16];
byte[] net = netGuid.ToByteArray();
for (int i = 8; i < 16; i++)
{
java[i] = net[i];
}
java[0] = net[3];
java[1] = net[2];
java[2] = net[1];
java[3] = net[0];
java[4] = net[5];
java[5] = net[4];
java[6] = net[7];
java[7] = net[6];
return new Guid(java);
}
/// <summary>
/// Converts little-endian .NET guids to big-endian Java guids:
/// </summary>
public static byte[] ToBigEndianBytes(this Guid netGuid)
{
byte[] java = new byte[16];
byte[] net = netGuid.ToByteArray();
for (int i = 8; i < 16; i++)
{
java[i] = net[i];
}
java[0] = net[3];
java[1] = net[2];
java[2] = net[1];
java[3] = net[0];
java[4] = net[5];
java[5] = net[4];
java[6] = net[7];
java[7] = net[6];
return java;
}
}
}