mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
AntiCheat fix prevent Block Breaking
This commit is contained in:
parent
9a147b57e5
commit
fde50c1728
6 changed files with 15 additions and 14 deletions
|
|
@ -285,7 +285,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (Config.Mode == Configs.ModeType.lookat ||
|
||||
(Config.Mode == Configs.ModeType.both && Config._Locations.Contains(blockLoc)))
|
||||
{
|
||||
if (DigBlock(blockLoc, lookAtBlock: false))
|
||||
if (DigBlock(blockLoc, Direction.Down, lookAtBlock: false))
|
||||
{
|
||||
currentDig = blockLoc;
|
||||
if (Config.Log_Block_Dig)
|
||||
|
|
@ -346,7 +346,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
if (minDistance <= 6.0)
|
||||
{
|
||||
if (DigBlock(target, lookAtBlock: true))
|
||||
if (DigBlock(target, Direction.Down, lookAtBlock: true))
|
||||
{
|
||||
currentDig = target;
|
||||
if (Config.Log_Block_Dig)
|
||||
|
|
@ -380,7 +380,7 @@ namespace MinecraftClient.ChatBots
|
|||
((Config.List_Type == Configs.ListType.whitelist && Config.Blocks.Contains(block.Type)) ||
|
||||
(Config.List_Type == Configs.ListType.blacklist && !Config.Blocks.Contains(block.Type))))
|
||||
{
|
||||
if (DigBlock(blockLoc, lookAtBlock: true))
|
||||
if (DigBlock(blockLoc, Direction.Down, lookAtBlock: true))
|
||||
{
|
||||
currentDig = blockLoc;
|
||||
if (Config.Log_Block_Dig)
|
||||
|
|
|
|||
|
|
@ -831,7 +831,7 @@ namespace MinecraftClient.ChatBots
|
|||
// Yoinked from Daenges's Sugarcane Farmer
|
||||
private bool WaitForDigBlock(Location block, int digTimeout = 1000)
|
||||
{
|
||||
if (!DigBlock(block.ToFloor())) return false;
|
||||
if (!DigBlock(block.ToFloor(), Direction.Down)) return false;
|
||||
short i = 0; // Maximum wait time of 10 sec.
|
||||
while (GetWorld().GetBlock(block).Type != Material.Air && i <= digTimeout)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -651,9 +651,10 @@ public class WebSocketBot : ChatBot
|
|||
|
||||
var result = cmd.Parameters.Length switch
|
||||
{
|
||||
3 => DigBlock(location),
|
||||
4 => DigBlock(location, (bool)cmd.Parameters[3]),
|
||||
5 => DigBlock(location, (bool)cmd.Parameters[3], (bool)cmd.Parameters[4]),
|
||||
// TODO Get Direction from the 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]),
|
||||
_ => false
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace MinecraftClient.Commands
|
|||
Block block = handler.GetWorld().GetBlock(blockToBreak);
|
||||
if (block.Type == Material.Air)
|
||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
||||
else if (handler.DigBlock(blockToBreak, duration: duration))
|
||||
else if (handler.DigBlock(blockToBreak, Direction.Down, duration: duration))
|
||||
{
|
||||
blockToBreak = blockToBreak.ToCenter();
|
||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.GetTypeString()));
|
||||
|
|
@ -78,7 +78,7 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_too_far);
|
||||
else if (block.Type == Material.Air)
|
||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
||||
else if (handler.DigBlock(blockLoc, lookAtBlock: false, duration: duration))
|
||||
else if (handler.DigBlock(blockLoc, Direction.Down, lookAtBlock: false, duration: duration))
|
||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString()));
|
||||
else
|
||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_fail);
|
||||
|
|
|
|||
|
|
@ -2266,16 +2266,15 @@ namespace MinecraftClient
|
|||
/// <param name="location">Location of block to dig</param>
|
||||
/// <param name="swingArms">Also perform the "arm swing" animation</param>
|
||||
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
||||
public bool DigBlock(Location location, 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)
|
||||
{
|
||||
if (!GetTerrainEnabled())
|
||||
return false;
|
||||
|
||||
if (InvokeRequired)
|
||||
return InvokeOnMainThread(() => DigBlock(location, swingArms, lookAtBlock, duration));
|
||||
return InvokeOnMainThread(() => DigBlock(location, blockFace, swingArms, lookAtBlock, duration));
|
||||
|
||||
// TODO select best face from current player location
|
||||
Direction blockFace = Direction.Down;
|
||||
|
||||
lock (DigLock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1072,11 +1072,12 @@ namespace MinecraftClient.Scripting
|
|||
/// Attempt to dig a block at the specified location
|
||||
/// </summary>
|
||||
/// <param name="location">Location of block to dig</param>
|
||||
/// <param name="direction">Example: if your player is under a block that is being destroyed, use Down</param>
|
||||
/// <param name="swingArms">Also perform the "arm swing" animation</param>
|
||||
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
||||
protected bool DigBlock(Location location, bool swingArms = true, bool lookAtBlock = true)
|
||||
protected bool DigBlock(Location location, Direction direction, bool swingArms = true, bool lookAtBlock = true)
|
||||
{
|
||||
return Handler.DigBlock(location, swingArms, lookAtBlock);
|
||||
return Handler.DigBlock(location, direction, swingArms, lookAtBlock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue