From 20f6375153cbad91d2d111a4baa9f10ae39b2c17 Mon Sep 17 00:00:00 2001 From: ORelio Date: Sat, 14 Nov 2020 10:19:51 +0100 Subject: [PATCH] Merge #1332 and #1333 Add optional arguments to DigBlock() --- MinecraftClient/ChatBot.cs | 8 +++++--- MinecraftClient/McClient.cs | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index b9996933..7b333d70 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -860,10 +860,12 @@ namespace MinecraftClient /// /// Attempt to dig a block at the specified location /// - /// Location - protected bool DigBlock(Location location) + /// Location of block to dig + /// Also perform the "arm swing" animation + /// Also look at the block before digging + protected bool DigBlock(Location location, bool swingArms = true, bool lookAtBlock = true) { - return Handler.DigBlock(location); + return Handler.DigBlock(location, swingArms, lookAtBlock); } /// diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 6883db9d..b631cb96 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1402,7 +1402,8 @@ namespace MinecraftClient /// /// Location of block to dig /// Also perform the "arm swing" animation - public bool DigBlock(Location location, bool swingArms = true) + /// Also look at the block before digging + public bool DigBlock(Location location, bool swingArms = true, bool lookAtBlock = true) { if (GetTerrainEnabled()) { @@ -1410,7 +1411,8 @@ namespace MinecraftClient Direction blockFace = Direction.Down; // Look at block before attempting to break it - UpdateLocation(GetCurrentLocation(), location); + if (lookAtBlock) + UpdateLocation(GetCurrentLocation(), location); // Send dig start and dig end, will need to wait for server response to know dig result // See https://wiki.vg/How_to_Write_a_Client#Digging for more details