From 384c804e549dcd42d3310238943848166f80921e Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 08:28:22 -0500 Subject: [PATCH 01/23] Added Entity Action handling, and A TSneak command that will Toggle Sneak. --- MinecraftClient/ChatBots/AutoLook.cs | 66 +++++++++++++++++++ MinecraftClient/Commands/Sneak.cs | 31 +++++++++ MinecraftClient/McTcpClient.cs | 11 ++++ MinecraftClient/MinecraftClient.csproj | 3 + MinecraftClient/Protocol/Action.cs | 16 +++++ .../Protocol/Handlers/PacketOutgoingType.cs | 3 +- .../Protocol/Handlers/Protocol16.cs | 4 ++ .../Protocol/Handlers/Protocol18.cs | 16 +++++ MinecraftClient/Protocol/IMinecraftCom.cs | 10 ++- MinecraftClient/Settings.cs | 21 +++++- 10 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 MinecraftClient/ChatBots/AutoLook.cs create mode 100644 MinecraftClient/Commands/Sneak.cs create mode 100644 MinecraftClient/Protocol/Action.cs diff --git a/MinecraftClient/ChatBots/AutoLook.cs b/MinecraftClient/ChatBots/AutoLook.cs new file mode 100644 index 00000000..053d63b0 --- /dev/null +++ b/MinecraftClient/ChatBots/AutoLook.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MinecraftClient.Mapping; + +namespace MinecraftClient.ChatBots +{ + public class AutoLook : ChatBot + { + private Entity _entityToLookAt; + public override void Initialize() + { + if (GetEntityHandlingEnabled() && GetTerrainEnabled()) return; + LogToConsole("Entity Handling or Terrain Handling is not enabled in the config file!"); + LogToConsole("This bot will be unloaded."); + UnloadBot(); + } + + public override void OnEntityDespawn(Entity entity) + { + if (entity == _entityToLookAt) + { + _entityToLookAt = null; + } + } + public override void OnEntitySpawn(Entity entity) + { + HandleEntity(entity); + } + public override void OnEntityMove(Entity entity) + { + var tempBool = HandleEntity(entity); + LogDebugToConsole(tempBool); + if (!tempBool) return; + LookAtLocation(entity.Location); + } + + /// + /// Handles an entity, and tracks it if it is closer then the one we are currently tracking + /// + /// True if found + private bool HandleEntity(Entity entity) + { + if (entity.Type != EntityType.Player) + { + return false; + } + if (_entityToLookAt == null) + { + _entityToLookAt = entity; + return true; + } + if (GetCurrentLocation().Distance(entity.Location) < GetCurrentLocation().Distance(_entityToLookAt.Location)) + { + _entityToLookAt = entity; + return true; + } + + if (entity.ID != _entityToLookAt.ID) return false; + _entityToLookAt = entity; //Handle looking at the same entity + return true; + + } + + } +} \ No newline at end of file diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs new file mode 100644 index 00000000..ada8b00b --- /dev/null +++ b/MinecraftClient/Commands/Sneak.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MinecraftClient.Commands +{ + public class Sneak : Command + { + private bool sneaking = false; + public override string CMDName { get { return "TSneak"; } } + public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } } + + public override string Run(McTcpClient handler, string command, Dictionary localVars) + { + if (sneaking) + { + var result = handler.sendEntityAction(Protocol.ActionType.StopSneaking); + sneaking = false; + return result ? "Success" : "Fail"; + } + else + { + var result = handler.sendEntityAction(Protocol.ActionType.StartSneaking); + sneaking = true; + return result ? "Success" : "Fail"; + } + + } + } +} \ No newline at end of file diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index d95af69d..340883a1 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -170,6 +170,8 @@ namespace MinecraftClient if (Settings.AutoAttack_Enabled) { BotLoad(new ChatBots.AutoAttack()); } if (Settings.AutoFishing_Enabled) { BotLoad(new ChatBots.AutoFishing()); } if (Settings.AutoEat_Enabled) { BotLoad(new ChatBots.AutoEat(Settings.AutoEat_hungerThreshold)); } + if (Settings.AutoLook_Enabled) { BotLoad(new ChatBots.AutoLook()); } + //Add your ChatBot here by uncommenting and adapting //BotLoad(new ChatBots.YourBot()); } @@ -1356,6 +1358,7 @@ namespace MinecraftClient } } + /// /// Called when an entity moved over 8 block. /// @@ -1469,6 +1472,14 @@ namespace MinecraftClient playerEntityID = EntityID; } + /// + /// Send the Entity Action packet with the Specified ID + /// + /// TRUE if the item was successfully used + public bool sendEntityAction(ActionType action) + { + return handler.SendEntityAction(playerEntityID, (int) action); + } /// /// Use the item currently in the player's hand /// diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index b13b53a3..84871504 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -78,6 +78,7 @@ + @@ -103,6 +104,7 @@ + @@ -119,6 +121,7 @@ + diff --git a/MinecraftClient/Protocol/Action.cs b/MinecraftClient/Protocol/Action.cs new file mode 100644 index 00000000..9e854f6e --- /dev/null +++ b/MinecraftClient/Protocol/Action.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MinecraftClient.Protocol +{ + public enum ActionType + { + StartSneaking, + StopSneaking, + LeaveBed, + StartSprinting, + StopSprinting + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs b/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs index 753558fa..5236aada 100644 --- a/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs +++ b/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs @@ -17,6 +17,7 @@ namespace MinecraftClient.Protocol.Handlers ClientSettings, PluginMessage, TabComplete, + EntityAction, PlayerPosition, PlayerPositionAndLook, TeleportConfirm, @@ -27,4 +28,4 @@ namespace MinecraftClient.Protocol.Handlers CloseWindow, PlayerBlockPlacement } -} +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index 58b2aa1f..cf28f67c 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -239,6 +239,10 @@ namespace MinecraftClient.Protocol.Handlers } else return ""; } + public bool SendEntityAction(int PlayerEntityID, int ActionID) + { + return true; + } private byte[] readNextByteArray() { diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index fab2c9fc..d63241a1 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -965,6 +965,22 @@ namespace MinecraftClient.Protocol.Handlers catch (System.IO.IOException) { return false; } catch (ObjectDisposedException) { return false; } } + + public bool SendEntityAction(int PlayerEntityID, int ActionID) + { + try + { + List fields = new List(); + fields.AddRange(dataTypes.GetVarInt(PlayerEntityID)); + fields.AddRange(dataTypes.GetVarInt(ActionID)); + fields.AddRange(dataTypes.GetVarInt(0)); + SendPacket(PacketOutgoingType.EntityAction, fields); + return true; + } + catch (SocketException) { return false; } + catch (System.IO.IOException) { return false; } + catch (ObjectDisposedException) { return false; } + } /// /// Send a respawn packet to the server diff --git a/MinecraftClient/Protocol/IMinecraftCom.cs b/MinecraftClient/Protocol/IMinecraftCom.cs index 1b876db1..00e57790 100644 --- a/MinecraftClient/Protocol/IMinecraftCom.cs +++ b/MinecraftClient/Protocol/IMinecraftCom.cs @@ -85,7 +85,15 @@ namespace MinecraftClient.Protocol /// packet Data /// True if message was successfully sent bool SendPluginChannelPacket(string channel, byte[] data); - + + /// + /// Send Entity Action packet to the server. + /// + /// PlayerID + /// Type of packet to send + /// True if packet was successfully sent + bool SendEntityAction(int EntityID, int type); + /// /// Send a held item change packet to the server. /// diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index fca92a25..bebf12bb 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -161,13 +161,16 @@ namespace MinecraftClient //Auto Eating public static bool AutoEat_Enabled = false; public static int AutoEat_hungerThreshold = 6; + + //Auto Looking + public static bool AutoLook_Enabled = false; //Custom app variables and Minecraft accounts private static readonly Dictionary AppVars = new Dictionary(); private static readonly Dictionary> Accounts = new Dictionary>(); private static readonly Dictionary> Servers = new Dictionary>(); - private enum ParseMode { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat }; + private enum ParseMode { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat, AutoLook }; /// /// Load settings from the give INI file @@ -211,6 +214,7 @@ namespace MinecraftClient case "autoattack": pMode = ParseMode.AutoAttack; break; case "autofishing": pMode = ParseMode.AutoFishing; break; case "autoeat": pMode = ParseMode.AutoEat; break; + case "autolook": pMode = ParseMode.AutoLook; break; default: pMode = ParseMode.Default; break; } } @@ -466,6 +470,12 @@ namespace MinecraftClient case "matchesfile": AutoRespond_Matches = argValue; break; } break; + case ParseMode.AutoLook: + switch (argName.ToLower()) + { + case "enabled": AutoLook_Enabled = str2bool(argValue); break; + } + break; case ParseMode.AutoAttack: switch (argName.ToLower()) @@ -689,12 +699,17 @@ namespace MinecraftClient + "\r\n" + "[AutoFishing]\r\n" + "# Entity Handling NEED to be enabled first\r\n" - + "enabled=false" + + "enabled=false\r\n" + "\r\n" + "[AutoEat]\r\n" + "# Inventory Handling NEED to be enabled first\r\n" + "enabled=false\r\n" - + "threshold=6", Encoding.UTF8); + + "threshold=6\r\n" + + "\r\n" + + "[AutoLook]\r\n" + + "# Entity Handling AND Terrain Handling NEEDS to be enabled first\r\n" + + "enabled=false" + + "\r\n", Encoding.UTF8); } /// From 16959d6e65f55c851c3bb45a943d98e09efaa66f Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 08:28:22 -0500 Subject: [PATCH 02/23] Remove AutoLook.cs Chatbot because it is not in main project. Also removes it in McTcpClient.cs, and gets rid of the Settings.cs and Default paramaters. --- MinecraftClient/ChatBots/AutoLook.cs | 66 -------------------------- MinecraftClient/McTcpClient.cs | 1 - MinecraftClient/MinecraftClient.csproj | 1 - MinecraftClient/Settings.cs | 14 +----- 4 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 MinecraftClient/ChatBots/AutoLook.cs diff --git a/MinecraftClient/ChatBots/AutoLook.cs b/MinecraftClient/ChatBots/AutoLook.cs deleted file mode 100644 index 053d63b0..00000000 --- a/MinecraftClient/ChatBots/AutoLook.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MinecraftClient.Mapping; - -namespace MinecraftClient.ChatBots -{ - public class AutoLook : ChatBot - { - private Entity _entityToLookAt; - public override void Initialize() - { - if (GetEntityHandlingEnabled() && GetTerrainEnabled()) return; - LogToConsole("Entity Handling or Terrain Handling is not enabled in the config file!"); - LogToConsole("This bot will be unloaded."); - UnloadBot(); - } - - public override void OnEntityDespawn(Entity entity) - { - if (entity == _entityToLookAt) - { - _entityToLookAt = null; - } - } - public override void OnEntitySpawn(Entity entity) - { - HandleEntity(entity); - } - public override void OnEntityMove(Entity entity) - { - var tempBool = HandleEntity(entity); - LogDebugToConsole(tempBool); - if (!tempBool) return; - LookAtLocation(entity.Location); - } - - /// - /// Handles an entity, and tracks it if it is closer then the one we are currently tracking - /// - /// True if found - private bool HandleEntity(Entity entity) - { - if (entity.Type != EntityType.Player) - { - return false; - } - if (_entityToLookAt == null) - { - _entityToLookAt = entity; - return true; - } - if (GetCurrentLocation().Distance(entity.Location) < GetCurrentLocation().Distance(_entityToLookAt.Location)) - { - _entityToLookAt = entity; - return true; - } - - if (entity.ID != _entityToLookAt.ID) return false; - _entityToLookAt = entity; //Handle looking at the same entity - return true; - - } - - } -} \ No newline at end of file diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 340883a1..5651761a 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -170,7 +170,6 @@ namespace MinecraftClient if (Settings.AutoAttack_Enabled) { BotLoad(new ChatBots.AutoAttack()); } if (Settings.AutoFishing_Enabled) { BotLoad(new ChatBots.AutoFishing()); } if (Settings.AutoEat_Enabled) { BotLoad(new ChatBots.AutoEat(Settings.AutoEat_hungerThreshold)); } - if (Settings.AutoLook_Enabled) { BotLoad(new ChatBots.AutoLook()); } //Add your ChatBot here by uncommenting and adapting //BotLoad(new ChatBots.YourBot()); diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 84871504..590438b1 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -78,7 +78,6 @@ - diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index bebf12bb..c1ecb9cd 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -170,7 +170,7 @@ namespace MinecraftClient private static readonly Dictionary> Accounts = new Dictionary>(); private static readonly Dictionary> Servers = new Dictionary>(); - private enum ParseMode { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat, AutoLook }; + private enum ParseMode { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat }; /// /// Load settings from the give INI file @@ -214,7 +214,6 @@ namespace MinecraftClient case "autoattack": pMode = ParseMode.AutoAttack; break; case "autofishing": pMode = ParseMode.AutoFishing; break; case "autoeat": pMode = ParseMode.AutoEat; break; - case "autolook": pMode = ParseMode.AutoLook; break; default: pMode = ParseMode.Default; break; } } @@ -470,13 +469,6 @@ namespace MinecraftClient case "matchesfile": AutoRespond_Matches = argValue; break; } break; - case ParseMode.AutoLook: - switch (argName.ToLower()) - { - case "enabled": AutoLook_Enabled = str2bool(argValue); break; - } - break; - case ParseMode.AutoAttack: switch (argName.ToLower()) { @@ -705,10 +697,6 @@ namespace MinecraftClient + "# Inventory Handling NEED to be enabled first\r\n" + "enabled=false\r\n" + "threshold=6\r\n" - + "\r\n" - + "[AutoLook]\r\n" - + "# Entity Handling AND Terrain Handling NEEDS to be enabled first\r\n" - + "enabled=false" + "\r\n", Encoding.UTF8); } From ff92aeab859b9ef55043dcbb07ef7412a262fbd8 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 09:26:51 -0500 Subject: [PATCH 03/23] Add some features of command logging --- MinecraftClient/Commands/Sneak.cs | 1 + MinecraftClient/McTcpClient.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index ada8b00b..8c8240b7 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -13,6 +13,7 @@ namespace MinecraftClient.Commands public override string Run(McTcpClient handler, string command, Dictionary localVars) { + Console.WriteLine(command); if (sneaking) { var result = handler.sendEntityAction(Protocol.ActionType.StopSneaking); diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 5651761a..8234133b 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -325,6 +325,7 @@ namespace MinecraftClient } while (true); } + /// /// Perform an internal MCC command (not a server command, use SendText() instead for that!) @@ -335,6 +336,7 @@ namespace MinecraftClient /// TRUE if the command was indeed an internal MCC command public bool PerformInternalCommand(string command, ref string response_msg, Dictionary localVars = null) { + /* Load commands from the 'Commands' namespace */ if (cmds.Count == 0) @@ -383,12 +385,28 @@ namespace MinecraftClient else if (cmds.ContainsKey(command_name)) { response_msg = cmds[command_name].Run(this, command, localVars); + foreach (ChatBot bot in bots.ToArray()) + { + try + { + bot.OnInternalCommand(command_name, response_msg); + } + catch (Exception e) + { + if (!(e is ThreadAbortException)) + { + ConsoleIO.WriteLogLine("OnInternalCommand: Got error from " + bot.ToString() + ": " + e.ToString()); + } + else throw; //ThreadAbortException should not be caught + } + } } else { response_msg = "Unknown command '" + command_name + "'. Use '" + (Settings.internalCmdChar == ' ' ? "" : "" + Settings.internalCmdChar) + "help' for help."; return false; } + return true; } From cd3b6a084500eee8854b0eeae7bcc86df78d0344 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 09:28:33 -0500 Subject: [PATCH 04/23] Add the EntityAction Outgoing type. --- MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs index 68ffef0a..3bdb2f56 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs @@ -310,6 +310,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.TeleportConfirm: throw new InvalidOperationException("Teleport confirm is not supported in protocol " + protocol); case PacketOutgoingType.ClickWindow: return 0x0E; case PacketOutgoingType.CloseWindow: return 0x0D; + case PacketOutgoingType.EntityAction: return 0x0B; } } else if (protocol <= Protocol18Handler.MC1112Version) // MC 1.9, 1,10 and 1.11 @@ -330,6 +331,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.InteractEntity: return 0x0A; case PacketOutgoingType.ClickWindow: return 0x07; case PacketOutgoingType.CloseWindow: return 0x08; + case PacketOutgoingType.EntityAction: return 0x0B; } } else if (protocol <= Protocol18Handler.MC112Version) // MC 1.12 @@ -350,6 +352,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.InteractEntity: return 0x0B; case PacketOutgoingType.ClickWindow: return 0x07; case PacketOutgoingType.CloseWindow: return 0x08; + case PacketOutgoingType.EntityAction: return 0x0B; } } else if (protocol <= Protocol18Handler.MC1122Version) // 1.12.2 @@ -370,6 +373,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.InteractEntity: return 0x0A; case PacketOutgoingType.ClickWindow: return 0x07; case PacketOutgoingType.CloseWindow: return 0x08; + case PacketOutgoingType.EntityAction: return 0x0B; } } else if (protocol < Protocol18Handler.MC114Version) // MC 1.13 to 1.13.2 @@ -390,6 +394,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.InteractEntity: return 0x0D; case PacketOutgoingType.ClickWindow: return 0x08; case PacketOutgoingType.CloseWindow: return 0x09; + case PacketOutgoingType.EntityAction: return 0x0B; } } else // MC 1.14 to 1.15 @@ -412,6 +417,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.PlayerBlockPlacement: return 0x2C; case PacketOutgoingType.ClickWindow: return 0x09; case PacketOutgoingType.CloseWindow: return 0x0A; + case PacketOutgoingType.EntityAction: return 0x0B; } } From 02ebf067b988a83160a9093c5c26eacd0004a902 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 09:37:15 -0500 Subject: [PATCH 05/23] Add Internal command logging. --- MinecraftClient/ChatBot.cs | 2 ++ MinecraftClient/ChatBots/ChatLog.cs | 18 +++++++++++++++++- MinecraftClient/McTcpClient.cs | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 538b91c2..22990942 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -156,6 +156,8 @@ namespace MinecraftClient /// Entity with updated location public virtual void OnEntityMove(Mapping.Entity entity) { } + public virtual void OnInternalCommand(string commandName,string commandParams, string Result) { } + /// /// Called when an entity spawned nearby /// diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index 38faec79..6ec8900f 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -12,11 +12,12 @@ namespace MinecraftClient.ChatBots public class ChatLog : ChatBot { - public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers }; + public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers, OnlyInternal }; private bool dateandtime; private bool saveOther = true; private bool saveChat = true; private bool savePrivate = true; + private bool saveInternal = true; private string logfile; /// @@ -52,6 +53,12 @@ namespace MinecraftClient.ChatBots savePrivate = true; saveChat = false; break; + case MessageFilter.OnlyInternal: + saveOther = false; + savePrivate = false; + saveChat = false; + saveInternal = true; + break; } if (String.IsNullOrEmpty(file) || file.IndexOfAny(Path.GetInvalidPathChars()) >= 0) { @@ -68,6 +75,7 @@ namespace MinecraftClient.ChatBots case "messages": return MessageFilter.AllMessages; case "chat": return MessageFilter.OnlyChat; case "private": return MessageFilter.OnlyWhispers; + case "internal": return MessageFilter.OnlyInternal; default: return MessageFilter.AllText; } } @@ -92,6 +100,14 @@ namespace MinecraftClient.ChatBots } } + public override void OnInternalCommand(string commandName,string commandParams, string Result) + { + if (saveInternal) + { + save($"Internal {commandName}({commandParams}): {Result}"); + } + } + private void save(string tosave) { if (dateandtime) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 8234133b..559d48ea 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -389,7 +389,7 @@ namespace MinecraftClient { try { - bot.OnInternalCommand(command_name, response_msg); + bot.OnInternalCommand(command_name, string.Join(" ",Command.getArgs(command)),response_msg); } catch (Exception e) { From bdf37e427c2933561e0c25669b4c836da49e224a Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 09:26:51 -0500 Subject: [PATCH 06/23] Add some features of command logging --- MinecraftClient/Commands/Sneak.cs | 1 + MinecraftClient/McTcpClient.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index ada8b00b..8c8240b7 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -13,6 +13,7 @@ namespace MinecraftClient.Commands public override string Run(McTcpClient handler, string command, Dictionary localVars) { + Console.WriteLine(command); if (sneaking) { var result = handler.sendEntityAction(Protocol.ActionType.StopSneaking); diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 5651761a..8234133b 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -325,6 +325,7 @@ namespace MinecraftClient } while (true); } + /// /// Perform an internal MCC command (not a server command, use SendText() instead for that!) @@ -335,6 +336,7 @@ namespace MinecraftClient /// TRUE if the command was indeed an internal MCC command public bool PerformInternalCommand(string command, ref string response_msg, Dictionary localVars = null) { + /* Load commands from the 'Commands' namespace */ if (cmds.Count == 0) @@ -383,12 +385,28 @@ namespace MinecraftClient else if (cmds.ContainsKey(command_name)) { response_msg = cmds[command_name].Run(this, command, localVars); + foreach (ChatBot bot in bots.ToArray()) + { + try + { + bot.OnInternalCommand(command_name, response_msg); + } + catch (Exception e) + { + if (!(e is ThreadAbortException)) + { + ConsoleIO.WriteLogLine("OnInternalCommand: Got error from " + bot.ToString() + ": " + e.ToString()); + } + else throw; //ThreadAbortException should not be caught + } + } } else { response_msg = "Unknown command '" + command_name + "'. Use '" + (Settings.internalCmdChar == ' ' ? "" : "" + Settings.internalCmdChar) + "help' for help."; return false; } + return true; } From 06ea43f6c01c2d26bc3376a56596de565bddbf98 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 09:37:15 -0500 Subject: [PATCH 07/23] Add Internal command logging. --- MinecraftClient/ChatBot.cs | 2 ++ MinecraftClient/ChatBots/ChatLog.cs | 18 +++++++++++++++++- MinecraftClient/McTcpClient.cs | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 538b91c2..22990942 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -156,6 +156,8 @@ namespace MinecraftClient /// Entity with updated location public virtual void OnEntityMove(Mapping.Entity entity) { } + public virtual void OnInternalCommand(string commandName,string commandParams, string Result) { } + /// /// Called when an entity spawned nearby /// diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index 38faec79..6ec8900f 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -12,11 +12,12 @@ namespace MinecraftClient.ChatBots public class ChatLog : ChatBot { - public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers }; + public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers, OnlyInternal }; private bool dateandtime; private bool saveOther = true; private bool saveChat = true; private bool savePrivate = true; + private bool saveInternal = true; private string logfile; /// @@ -52,6 +53,12 @@ namespace MinecraftClient.ChatBots savePrivate = true; saveChat = false; break; + case MessageFilter.OnlyInternal: + saveOther = false; + savePrivate = false; + saveChat = false; + saveInternal = true; + break; } if (String.IsNullOrEmpty(file) || file.IndexOfAny(Path.GetInvalidPathChars()) >= 0) { @@ -68,6 +75,7 @@ namespace MinecraftClient.ChatBots case "messages": return MessageFilter.AllMessages; case "chat": return MessageFilter.OnlyChat; case "private": return MessageFilter.OnlyWhispers; + case "internal": return MessageFilter.OnlyInternal; default: return MessageFilter.AllText; } } @@ -92,6 +100,14 @@ namespace MinecraftClient.ChatBots } } + public override void OnInternalCommand(string commandName,string commandParams, string Result) + { + if (saveInternal) + { + save($"Internal {commandName}({commandParams}): {Result}"); + } + } + private void save(string tosave) { if (dateandtime) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 8234133b..559d48ea 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -389,7 +389,7 @@ namespace MinecraftClient { try { - bot.OnInternalCommand(command_name, response_msg); + bot.OnInternalCommand(command_name, string.Join(" ",Command.getArgs(command)),response_msg); } catch (Exception e) { From 8b57b657e632dd301236974cd0f5ac6422b538fb Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 10:52:43 -0500 Subject: [PATCH 08/23] Add ChatBot methods to get inventories. --- MinecraftClient/ChatBot.cs | 4 ++++ MinecraftClient/McTcpClient.cs | 1 + 2 files changed, 5 insertions(+) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 22990942..5a251984 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -664,6 +664,10 @@ namespace MinecraftClient { return Handler.GetInventoryEnabled(); } + public Dictionary GetInventories() + { + return Handler.GetInventories(); + } /// /// Get the current Minecraft World diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 559d48ea..0a02eef7 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -6,6 +6,7 @@ using System.Net.Sockets; using System.Threading; using System.IO; using System.Net; +using MinecraftClient.ChatBots; using MinecraftClient.Protocol; using MinecraftClient.Proxy; using MinecraftClient.Protocol.Handlers.Forge; From 2fb4a9125218d8609d19d4ee792071116b7f7d04 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Fri, 1 May 2020 11:47:00 -0500 Subject: [PATCH 09/23] Fix the PacketID on 1.13.2 --- MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs index 3bdb2f56..feac66ab 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs @@ -394,7 +394,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.InteractEntity: return 0x0D; case PacketOutgoingType.ClickWindow: return 0x08; case PacketOutgoingType.CloseWindow: return 0x09; - case PacketOutgoingType.EntityAction: return 0x0B; + case PacketOutgoingType.EntityAction: return 0x19; } } else // MC 1.14 to 1.15 @@ -417,7 +417,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.PlayerBlockPlacement: return 0x2C; case PacketOutgoingType.ClickWindow: return 0x09; case PacketOutgoingType.CloseWindow: return 0x0A; - case PacketOutgoingType.EntityAction: return 0x0B; + case PacketOutgoingType.EntityAction: return 0x19; } } From 89c97c794c39e7424aff8584ea4c624914e2ce88 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sat, 2 May 2020 03:52:17 -0500 Subject: [PATCH 10/23] Add Chatbot API for accessing Using Hand and changing slot --- MinecraftClient/ChatBot.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 5a251984..67787247 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -668,6 +668,20 @@ namespace MinecraftClient { return Handler.GetInventories(); } + /// + /// Use item in hand + /// + protected void UseItemInHand() + { + Handler.UseItemOnHand(); + } + /// + /// SetSlot + /// + protected void SetSlot(int slotNum) + { + Handler.ChangeSlot((short) slotNum); + } /// /// Get the current Minecraft World From b2075bb8116889915fdea454ffd5f95cb1b3ef65 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sat, 2 May 2020 03:53:39 -0500 Subject: [PATCH 11/23] Add Chatbot API for accessing SendAction for things like Shift/Unshift --- MinecraftClient/ChatBot.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 67787247..a90a9600 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -676,6 +676,13 @@ namespace MinecraftClient Handler.UseItemOnHand(); } /// + /// Send Entity Action + /// + protected bool SendAction(Protocol.ActionType action) + { + return Handler.sendEntityAction(action); + } + /// /// SetSlot /// protected void SetSlot(int slotNum) From 799bc814c50976c2cc5070dc649d2c5d77415a81 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sat, 2 May 2020 03:55:23 -0500 Subject: [PATCH 12/23] Add Chatbot API for Sneaking / Unsneaking without using SendAction --- MinecraftClient/ChatBot.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index a90a9600..77e5196e 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -676,9 +676,23 @@ namespace MinecraftClient Handler.UseItemOnHand(); } /// + /// start Sneaking + /// + protected bool Sneak() + { + return SendAction(Protocol.ActionType.StartSneaking); + } + /// + /// Sends UnSneak + /// + protected bool UnSneak() + { + return SendAction(Protocol.ActionType.StopSneaking); + } + /// /// Send Entity Action /// - protected bool SendAction(Protocol.ActionType action) + private bool SendAction(Protocol.ActionType action) { return Handler.sendEntityAction(action); } From 7207a9ea0e267e7a2d33ff22b40be5ffa6d19414 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:48:02 -0500 Subject: [PATCH 13/23] Get rid of UseItemOnHand, in ChatBot.cs, function called UseItemInHand already does this (Same function). --- MinecraftClient/ChatBot.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 77e5196e..3fe03ff3 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -668,13 +668,7 @@ namespace MinecraftClient { return Handler.GetInventories(); } - /// - /// Use item in hand - /// - protected void UseItemInHand() - { - Handler.UseItemOnHand(); - } + /// /// start Sneaking /// @@ -903,7 +897,7 @@ namespace MinecraftClient /// Use item currently in the player's hand (active inventory bar slot) /// /// - protected bool UseItemOnHand() + protected bool UseItemInHand() { return Handler.UseItemOnHand(); } From c5a19f4b8b35ed08b4855ce5f691cc2cc0aa14bf Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:49:51 -0500 Subject: [PATCH 14/23] Get rid of UseItemOnHand in using chatbots, replace with UseItemInHand --- MinecraftClient/ChatBots/AutoEat.cs | 2 +- MinecraftClient/ChatBots/AutoFishing.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/ChatBots/AutoEat.cs b/MinecraftClient/ChatBots/AutoEat.cs index 7597ab90..0a32d7ac 100644 --- a/MinecraftClient/ChatBots/AutoEat.cs +++ b/MinecraftClient/ChatBots/AutoEat.cs @@ -83,7 +83,7 @@ namespace MinecraftClient.ChatBots } } } - if (found) UseItemOnHand(); + if (found) UseItemInHand(); return found; } } diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 92d22165..dc2d7432 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -95,7 +95,7 @@ namespace MinecraftClient.ChatBots { LogToConsole(GetTimestamp() + ": Caught a fish!"); // retract fishing rod - UseItemOnHand(); + UseItemInHand(); if (inventoryEnabled) { if (!hasFishingRod()) @@ -110,7 +110,7 @@ namespace MinecraftClient.ChatBots // retract fishing rod need some time Thread.Sleep(800); // throw again - UseItemOnHand(); + UseItemInHand(); }); } From add1dd2dcd705c25b61a55f348614dc67fbba5bc Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:51:50 -0500 Subject: [PATCH 15/23] Merge Unseak and sneak into one function --- MinecraftClient/ChatBot.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 3fe03ff3..358c4aed 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -672,16 +672,9 @@ namespace MinecraftClient /// /// start Sneaking /// - protected bool Sneak() + protected bool Sneak(bool on) { - return SendAction(Protocol.ActionType.StartSneaking); - } - /// - /// Sends UnSneak - /// - protected bool UnSneak() - { - return SendAction(Protocol.ActionType.StopSneaking); + return SendAction(on ? Protocol.ActionType.StartSneaking : Protocol.ActionType.StopSneaking); } /// /// Send Entity Action From a78623bf84bbe143d72afc6e47a881b296472d90 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:52:58 -0500 Subject: [PATCH 16/23] Rename SendAction to SendEntityAction in ChatBot.cs --- MinecraftClient/ChatBot.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 358c4aed..bf125fc2 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -674,12 +674,12 @@ namespace MinecraftClient /// protected bool Sneak(bool on) { - return SendAction(on ? Protocol.ActionType.StartSneaking : Protocol.ActionType.StopSneaking); + return SendEntityAction(on ? Protocol.ActionType.StartSneaking : Protocol.ActionType.StopSneaking); } /// /// Send Entity Action /// - private bool SendAction(Protocol.ActionType action) + private bool SendEntityAction(Protocol.ActionType action) { return Handler.sendEntityAction(action); } From 2fdb89c11ae81d6d77888ad6e32fa80349deb19d Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:55:55 -0500 Subject: [PATCH 17/23] Change OnlyInternal to OnlyInternalCommands --- MinecraftClient/ChatBots/ChatLog.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index 6ec8900f..436a90ed 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -12,7 +12,7 @@ namespace MinecraftClient.ChatBots public class ChatLog : ChatBot { - public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers, OnlyInternal }; + public enum MessageFilter { AllText, AllMessages, OnlyChat, OnlyWhispers, OnlyInternalCommands }; private bool dateandtime; private bool saveOther = true; private bool saveChat = true; @@ -53,7 +53,7 @@ namespace MinecraftClient.ChatBots savePrivate = true; saveChat = false; break; - case MessageFilter.OnlyInternal: + case MessageFilter.OnlyInternalCommands: saveOther = false; savePrivate = false; saveChat = false; @@ -75,7 +75,7 @@ namespace MinecraftClient.ChatBots case "messages": return MessageFilter.AllMessages; case "chat": return MessageFilter.OnlyChat; case "private": return MessageFilter.OnlyWhispers; - case "internal": return MessageFilter.OnlyInternal; + case "internal": return MessageFilter.OnlyInternalCommands; default: return MessageFilter.AllText; } } From bb5ea0280a3b165d1384422e2152adfa97658990 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 10:56:55 -0500 Subject: [PATCH 18/23] Get rid of String interpolation, replace with string format. --- MinecraftClient/ChatBots/ChatLog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index 436a90ed..8714f937 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -104,7 +104,7 @@ namespace MinecraftClient.ChatBots { if (saveInternal) { - save($"Internal {commandName}({commandParams}): {Result}"); + save(string.Format("Internal {0}({1}): {2}", commandName, commandParams, Result)); } } From 5fdbff94c7bfa4a403376b63e33f47a7a890c470 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 11:18:18 -0500 Subject: [PATCH 19/23] Rename Result to result to be compliant. --- MinecraftClient/ChatBots/ChatLog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index 8714f937..dbd028e3 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -100,11 +100,11 @@ namespace MinecraftClient.ChatBots } } - public override void OnInternalCommand(string commandName,string commandParams, string Result) + public override void OnInternalCommand(string commandName,string commandParams, string result) { if (saveInternal) { - save(string.Format("Internal {0}({1}): {2}", commandName, commandParams, Result)); + save(string.Format("Internal {0}({1}): {2}", commandName, commandParams, result)); } } From 222a552c884d9605ffcdb4b839c15d3ca0e97757 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 11:19:22 -0500 Subject: [PATCH 20/23] Rename TSneak to Sneak --- MinecraftClient/Commands/Sneak.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index 8c8240b7..6fcd8c8c 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -8,7 +8,7 @@ namespace MinecraftClient.Commands public class Sneak : Command { private bool sneaking = false; - public override string CMDName { get { return "TSneak"; } } + public override string CMDName { get { return "Sneak"; } } public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } } public override string Run(McTcpClient handler, string command, Dictionary localVars) From 0cd7f2043b34813f803261a7f32f5a06bbbe8154 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 11:21:34 -0500 Subject: [PATCH 21/23] Rename Action to EntityActionType, Apply Rename refactoring. --- MinecraftClient/ChatBot.cs | 6 +++--- MinecraftClient/Commands/Sneak.cs | 4 ++-- MinecraftClient/McTcpClient.cs | 4 ++-- MinecraftClient/MinecraftClient.csproj | 2 +- MinecraftClient/Protocol/{Action.cs => EntityActionType.cs} | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename MinecraftClient/Protocol/{Action.cs => EntityActionType.cs} (88%) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index bf125fc2..e5f92b35 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -674,14 +674,14 @@ namespace MinecraftClient /// protected bool Sneak(bool on) { - return SendEntityAction(on ? Protocol.ActionType.StartSneaking : Protocol.ActionType.StopSneaking); + return SendEntityAction(on ? Protocol.EntityActionType.StartSneaking : Protocol.EntityActionType.StopSneaking); } /// /// Send Entity Action /// - private bool SendEntityAction(Protocol.ActionType action) + private bool SendEntityAction(Protocol.EntityActionType entityAction) { - return Handler.sendEntityAction(action); + return Handler.sendEntityAction(entityAction); } /// /// SetSlot diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index 6fcd8c8c..51067b53 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -16,13 +16,13 @@ namespace MinecraftClient.Commands Console.WriteLine(command); if (sneaking) { - var result = handler.sendEntityAction(Protocol.ActionType.StopSneaking); + var result = handler.sendEntityAction(Protocol.EntityActionType.StopSneaking); sneaking = false; return result ? "Success" : "Fail"; } else { - var result = handler.sendEntityAction(Protocol.ActionType.StartSneaking); + var result = handler.sendEntityAction(Protocol.EntityActionType.StartSneaking); sneaking = true; return result ? "Success" : "Fail"; } diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 0a02eef7..9881148a 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -1494,9 +1494,9 @@ namespace MinecraftClient /// Send the Entity Action packet with the Specified ID /// /// TRUE if the item was successfully used - public bool sendEntityAction(ActionType action) + public bool sendEntityAction(EntityActionType entityAction) { - return handler.SendEntityAction(playerEntityID, (int) action); + return handler.SendEntityAction(playerEntityID, (int) entityAction); } /// /// Use the item currently in the player's hand diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 590438b1..ed121f24 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -120,7 +120,7 @@ - + diff --git a/MinecraftClient/Protocol/Action.cs b/MinecraftClient/Protocol/EntityActionType.cs similarity index 88% rename from MinecraftClient/Protocol/Action.cs rename to MinecraftClient/Protocol/EntityActionType.cs index 9e854f6e..7d560e07 100644 --- a/MinecraftClient/Protocol/Action.cs +++ b/MinecraftClient/Protocol/EntityActionType.cs @@ -5,7 +5,7 @@ using System.Text; namespace MinecraftClient.Protocol { - public enum ActionType + public enum EntityActionType { StartSneaking, StopSneaking, From 04068cdb24bf24c95686cdfa4b51d23738430f76 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 11:22:41 -0500 Subject: [PATCH 22/23] Return False for unimplemented actions --- MinecraftClient/Protocol/Handlers/Protocol16.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index cf28f67c..f5f0d07d 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -241,7 +241,7 @@ namespace MinecraftClient.Protocol.Handlers } public bool SendEntityAction(int PlayerEntityID, int ActionID) { - return true; + return false; } private byte[] readNextByteArray() From 5a0f1068840222f19d21835fcc04bae2a4b17919 Mon Sep 17 00:00:00 2001 From: CarbonNeuron Date: Sun, 3 May 2020 11:23:41 -0500 Subject: [PATCH 23/23] Get Rid of AutoLook setting. --- MinecraftClient/Settings.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index c1ecb9cd..2afcafd9 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -161,9 +161,6 @@ namespace MinecraftClient //Auto Eating public static bool AutoEat_Enabled = false; public static int AutoEat_hungerThreshold = 6; - - //Auto Looking - public static bool AutoLook_Enabled = false; //Custom app variables and Minecraft accounts private static readonly Dictionary AppVars = new Dictionary();