mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Spectator-Teleport Implementation (#1825)
This commit is contained in:
parent
4ba09754de
commit
76a10c0cd8
6 changed files with 88 additions and 0 deletions
|
|
@ -1339,6 +1339,24 @@ namespace MinecraftClient
|
|||
return Handler.SelectTrade(selectedSlot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Teleport to player in spectator mode
|
||||
/// </summary>
|
||||
/// <param name="entity">player to teleport to</param>
|
||||
protected bool SpectatorTeleport(Entity entity)
|
||||
{
|
||||
return Handler.Spectate(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Teleport to player/entity in spectator mode
|
||||
/// </summary>
|
||||
/// <param name="uuid">uuid of entity to teleport to</param>
|
||||
protected bool SpectatorTeleport(Guid UUID)
|
||||
{
|
||||
return Handler.SpectateByUUID(UUID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update command block
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1695,6 +1695,41 @@ namespace MinecraftClient
|
|||
{
|
||||
return InvokeOnMainThread(() => handler.UpdateCommandBlock(location, command, mode, flags));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Teleport to player in spectator mode
|
||||
/// </summary>
|
||||
/// <param name="entity">Player to teleport to</param>
|
||||
/// Teleporting to other entityies is NOT implemented yet
|
||||
public bool Spectate(Entity entity)
|
||||
{
|
||||
if(entity.Type == EntityType.Player)
|
||||
{
|
||||
return SpectateByUUID(entity.UUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Teleport to player/entity in spectator mode
|
||||
/// </summary>
|
||||
/// <param name="UUID">UUID of player/entity to teleport to</param>
|
||||
public bool SpectateByUUID(Guid UUID)
|
||||
{
|
||||
if(GetGamemode() == 3)
|
||||
{
|
||||
if(InvokeRequired)
|
||||
return InvokeOnMainThread(() => SpectateByUUID(UUID));
|
||||
return handler.SendSpectate(UUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event handlers: An event occurs on the Server
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -860,5 +860,10 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
return false; //MC 1.13+
|
||||
}
|
||||
|
||||
public bool SendSpectate(Guid UUID)
|
||||
{
|
||||
return false; //Currently not implemented
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,12 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="selectedSlot">The slot of the trade, starts at 0.</param>
|
||||
bool SelectTrade(int selectedSlot);
|
||||
|
||||
/// <summary>
|
||||
/// Spectate a player/entity
|
||||
/// </summary>
|
||||
/// <param name="uuid">The uuid of the player/entity to spectate/teleport to.</param>
|
||||
bool SendSpectate(Guid uuid);
|
||||
|
||||
/// <summary>
|
||||
/// Get net read thread (main thread) ID
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue