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

@ -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