Spectator-Teleport Implementation (#1825)

This commit is contained in:
xXjojaXx 2021-11-17 17:33:52 +01:00 committed by GitHub
parent 4ba09754de
commit 76a10c0cd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 88 additions and 0 deletions

View file

@ -1047,6 +1047,16 @@ namespace MinecraftClient.Protocol.Handlers
}
}
/// <summary>
/// Get a byte array from the given uuid
/// </summary>
/// <param name="uuid">UUID of Player/Entity</param>
/// <returns>UUID representation</returns>
public byte[] GetUUID(Guid UUID)
{
return UUID.ToBigEndianBytes();
}
/// <summary>
/// Easily append several byte arrays
/// </summary>

View file

@ -860,5 +860,10 @@ namespace MinecraftClient.Protocol.Handlers
{
return false; //MC 1.13+
}
public bool SendSpectate(Guid UUID)
{
return false; //Currently not implemented
}
}
}

View file

@ -2057,5 +2057,19 @@ namespace MinecraftClient.Protocol.Handlers
}
else { return false; }
}
public bool SendSpectate(Guid UUID)
{
try
{
List<byte> packet = new List<byte>();
packet.AddRange(dataTypes.GetUUID(UUID));
SendPacket(PacketTypesOut.Spectate, packet);
return true;
}
catch (SocketException) { return false; }
catch (System.IO.IOException) { return false; }
catch (ObjectDisposedException) { return false; }
}
}
}