diff --git a/MinecraftClient/ChatBots/WebSocketBot.cs b/MinecraftClient/ChatBots/WebSocketBot.cs index d4fc6842..778ff018 100644 --- a/MinecraftClient/ChatBots/WebSocketBot.cs +++ b/MinecraftClient/ChatBots/WebSocketBot.cs @@ -651,7 +651,7 @@ public class WebSocketBot : ChatBot var result = cmd.Parameters.Length switch { - // TODO Get Direction from the arguments + // TODO Get blockFace direction from arguments 3 => DigBlock(location, Direction.Down), 4 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3]), 5 => DigBlock(location, Direction.Down, (bool)cmd.Parameters[3], (bool)cmd.Parameters[4]), diff --git a/MinecraftClient/Commands/Dig.cs b/MinecraftClient/Commands/Dig.cs index b6ff9420..477e2c77 100644 --- a/MinecraftClient/Commands/Dig.cs +++ b/MinecraftClient/Commands/Dig.cs @@ -22,6 +22,7 @@ namespace MinecraftClient.Commands ); dispatcher.Register(l => l.Literal(CmdName) + // TODO Get blockFace direction from arguments .Executes(r => DigLookAt(r.Source)) .Then(l => l.Argument("Duration", Arguments.Double()) .Executes(r => DigLookAt(r.Source, Arguments.GetDouble(r, "Duration")))) diff --git a/MinecraftClient/Mapping/DirectionExtensions.cs b/MinecraftClient/Mapping/DirectionExtensions.cs new file mode 100644 index 00000000..fe47f020 --- /dev/null +++ b/MinecraftClient/Mapping/DirectionExtensions.cs @@ -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; + + } + } + } +} diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 786f35e1..b58e420e 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -2268,14 +2268,14 @@ namespace MinecraftClient /// Also look at the block before digging 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()) return false; if (InvokeRequired) return InvokeOnMainThread(() => DigBlock(location, blockFace, swingArms, lookAtBlock, duration)); - // TODO select best face from current player location - lock (DigLock) { if (RemainingDiggingTime > 0 && LastDigPosition != null)