mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Done auxiliary methods for Direction
This commit is contained in:
parent
91ef890bb6
commit
df9443381b
3 changed files with 44 additions and 1 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
namespace MinecraftClient.Mapping
|
using System;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Mapping
|
||||||
{
|
{
|
||||||
public static class DirectionExtensions
|
public static class DirectionExtensions
|
||||||
{
|
{
|
||||||
|
|
@ -35,5 +37,27 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Direction[] HORIZONTAL =
|
||||||
|
{
|
||||||
|
Direction.South,
|
||||||
|
Direction.West,
|
||||||
|
Direction.North,
|
||||||
|
Direction.East
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Direction FromRotation(double rotation)
|
||||||
|
{
|
||||||
|
double floor = Math.Floor((rotation / 90.0) + 0.5);
|
||||||
|
int value = (int)floor & 3;
|
||||||
|
|
||||||
|
return FromHorizontal(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Direction FromHorizontal(int value)
|
||||||
|
{
|
||||||
|
return HORIZONTAL[Math.Abs(value % HORIZONTAL.Length)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1036,6 +1036,15 @@ namespace MinecraftClient
|
||||||
|
|
||||||
#region Getters: Retrieve data for use in other methods or ChatBots
|
#region Getters: Retrieve data for use in other methods or ChatBots
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the horizontal direction of the takeoff.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Return direction of view</returns>
|
||||||
|
public Direction GetHorizontalFacing()
|
||||||
|
{
|
||||||
|
return DirectionExtensions.FromRotation(GetYaw());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get max length for chat messages
|
/// Get max length for chat messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2260,6 +2269,7 @@ namespace MinecraftClient
|
||||||
return InvokeOnMainThread(() => handler.SendPlayerBlockPlacement((int)hand, location, blockFace, sequenceId++));
|
return InvokeOnMainThread(() => handler.SendPlayerBlockPlacement((int)hand, location, blockFace, sequenceId++));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to dig a block at the specified location
|
/// Attempt to dig a block at the specified location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1631,6 +1631,15 @@ namespace MinecraftClient.Scripting
|
||||||
return Handler.GetProtocolVersion();
|
return Handler.GetProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the horizontal direction of the takeoff.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Return direction of view</returns>
|
||||||
|
protected Direction GetHorizontalFacing()
|
||||||
|
{
|
||||||
|
return Handler.GetHorizontalFacing();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoke a task on the main thread, wait for completion and retrieve return value.
|
/// Invoke a task on the main thread, wait for completion and retrieve return value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue