mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Auxiliary class for Direction, preparation for autodetection of the broken side of the block
This commit is contained in:
parent
fde50c1728
commit
91ef890bb6
4 changed files with 43 additions and 3 deletions
|
|
@ -651,7 +651,7 @@ public class WebSocketBot : ChatBot
|
||||||
|
|
||||||
var result = cmd.Parameters.Length switch
|
var result = cmd.Parameters.Length switch
|
||||||
{
|
{
|
||||||
// TODO Get Direction from the arguments
|
// TODO Get blockFace direction from arguments
|
||||||
3 => DigBlock(location, Direction.Down),
|
3 => DigBlock(location, Direction.Down),
|
||||||
4 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3]),
|
4 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3]),
|
||||||
5 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3], (bool)cmd.Parameters[4]),
|
5 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3], (bool)cmd.Parameters[4]),
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ namespace MinecraftClient.Commands
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatcher.Register(l => l.Literal(CmdName)
|
dispatcher.Register(l => l.Literal(CmdName)
|
||||||
|
// TODO Get blockFace direction from arguments
|
||||||
.Executes(r => DigLookAt(r.Source))
|
.Executes(r => DigLookAt(r.Source))
|
||||||
.Then(l => l.Argument("Duration", Arguments.Double())
|
.Then(l => l.Argument("Duration", Arguments.Double())
|
||||||
.Executes(r => DigLookAt(r.Source, Arguments.GetDouble(r, "Duration"))))
|
.Executes(r => DigLookAt(r.Source, Arguments.GetDouble(r, "Duration"))))
|
||||||
|
|
|
||||||
39
MinecraftClient/Mapping/DirectionExtensions.cs
Normal file
39
MinecraftClient/Mapping/DirectionExtensions.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
namespace MinecraftClient.Mapping
|
||||||
|
{
|
||||||
|
public static class DirectionExtensions
|
||||||
|
{
|
||||||
|
public static Direction GetOpposite(this Direction direction)
|
||||||
|
{
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case Direction.SouthEast:
|
||||||
|
return Direction.NorthEast;
|
||||||
|
case Direction.SouthWest:
|
||||||
|
return Direction.NorthWest;
|
||||||
|
|
||||||
|
case Direction.NorthEast:
|
||||||
|
return Direction.SouthEast;
|
||||||
|
case Direction.NorthWest:
|
||||||
|
return Direction.SouthWest;
|
||||||
|
|
||||||
|
case Direction.West:
|
||||||
|
return Direction.East;
|
||||||
|
case Direction.East:
|
||||||
|
return Direction.West;
|
||||||
|
|
||||||
|
case Direction.North:
|
||||||
|
return Direction.South;
|
||||||
|
case Direction.South:
|
||||||
|
return Direction.North;
|
||||||
|
|
||||||
|
case Direction.Down:
|
||||||
|
return Direction.Up;
|
||||||
|
case Direction.Up:
|
||||||
|
return Direction.Down;
|
||||||
|
default:
|
||||||
|
return Direction.Up;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2268,14 +2268,14 @@ namespace MinecraftClient
|
||||||
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
||||||
public bool DigBlock(Location location, Direction blockFace, bool swingArms = true, bool lookAtBlock = true, double duration = 0)
|
public bool DigBlock(Location location, Direction blockFace, bool swingArms = true, bool lookAtBlock = true, double duration = 0)
|
||||||
{
|
{
|
||||||
|
// TODO select best face from current player location
|
||||||
|
|
||||||
if (!GetTerrainEnabled())
|
if (!GetTerrainEnabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
return InvokeOnMainThread(() => DigBlock(location, blockFace, swingArms, lookAtBlock, duration));
|
return InvokeOnMainThread(() => DigBlock(location, blockFace, swingArms, lookAtBlock, duration));
|
||||||
|
|
||||||
// TODO select best face from current player location
|
|
||||||
|
|
||||||
lock (DigLock)
|
lock (DigLock)
|
||||||
{
|
{
|
||||||
if (RemainingDiggingTime > 0 && LastDigPosition != null)
|
if (RemainingDiggingTime > 0 && LastDigPosition != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue