diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index d8bd0544..611a1db4 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -823,11 +823,11 @@ namespace MinecraftClient /// /// Location to reach /// Allow possible but unsafe locations thay may hurt the player: lava, cactus... - /// Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins + /// Allow non-vanilla teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins /// True if a path has been found - protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowSmallTeleport = false) + protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowDirectTeleport = false) { - return Handler.MoveTo(location, allowUnsafe, allowSmallTeleport); + return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport); } /// @@ -1145,13 +1145,13 @@ namespace MinecraftClient /// /// Register a command in command prompt /// - /// Name of the command - /// Description/usage of the command - /// Method for handling the command + /// Name of the command + /// Description/usage of the command + /// Method for handling the command /// True if successfully registered - protected bool RegisterChatBotCommand(string CMDName, string CMDDesc, CommandRunner Run) + protected bool RegisterChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback) { - return Handler.RegisterCommand(CMDName, CMDDesc, Run); + return Handler.RegisterCommand(cmdName, cmdDesc, callback); } /// @@ -1160,7 +1160,7 @@ namespace MinecraftClient /// /// Full command /// Arguments in the command - /// + /// Command result to display to the user public delegate string CommandRunner(string command, string[] args); /// @@ -1170,24 +1170,28 @@ namespace MinecraftClient { public CommandRunner Runner; - public override string CMDName { get; } - public override string CMDDesc { get; } + private readonly string _cmdName; + private readonly string _cmdDesc; + + public override string CMDName { get { return _cmdName; } } + public override string CMDDesc { get { return _cmdDesc; } } + public override string Run(McClient handler, string command, Dictionary localVars) { return this.Runner(command, getArgs(command)); } /// - /// Constructor + /// ChatBotCommand Constructor /// /// Name of the command /// Description/usage of the command /// Method for handling the command - public ChatBotCommand(string CMDName, string CMDDesc, CommandRunner runner) + public ChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback) { - this.CMDName = CMDName; - this.CMDDesc = CMDDesc; - this.Runner = runner; + this._cmdName = cmdName; + this._cmdDesc = cmdDesc; + this.Runner = callback; } } } diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index ffc0e148..25228bda 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -581,29 +581,27 @@ namespace MinecraftClient } /// - /// Register a command prompt command + /// Register a custom console command /// - /// Name of the command - /// Description/usage of the command - /// Method for handling the command + /// Name of the command + /// Description/usage of the command + /// Method for handling the command /// True if successfully registered - public bool RegisterCommand(string CMDName, string CMDDesc, CommandRunner runner) + public bool RegisterCommand(string cmdName, string cmdDesc, ChatBot.CommandRunner callback) { - if (cmds.ContainsKey(CMDName.ToLower())) + if (cmds.ContainsKey(cmdName.ToLower())) { return false; } else { - Command cmd = new ChatBotCommand(CMDName, CMDDesc, runner); - cmds.Add(CMDName.ToLower(), cmd); - cmd_names.Add(CMDName.ToLower()); + Command cmd = new ChatBot.ChatBotCommand(cmdName, cmdDesc, callback); + cmds.Add(cmdName.ToLower(), cmd); + cmd_names.Add(cmdName.ToLower()); return true; } } - - #region Management: Load/Unload ChatBots and Enable/Disable settings /// @@ -828,15 +826,15 @@ namespace MinecraftClient /// /// Location to reach /// Allow possible but unsafe locations thay may hurt the player: lava, cactus... - /// Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins + /// Allow non-vanilla direct teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins /// True if a path has been found - public bool MoveTo(Location location, bool allowUnsafe = false, bool allowSmallTeleport = false) + public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false) { lock (locationLock) { - if (allowSmallTeleport) + if (allowDirectTeleport) { - // Allow small teleport within a range of 8 blocks. 1-step path to the desired location without checking anything + // 1-step path to the desired location without checking anything UpdateLocation(location, location); // Update yaw and pitch to look at next step handler.SendLocationUpdate(location, Movement.IsOnGround(world, location), yaw, pitch); return true; diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 8c763436..110e35bf 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -123,6 +123,8 @@ + + @@ -317,4 +319,4 @@ --> - + \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 8ab202ea..98b7e3a0 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -372,17 +372,17 @@ namespace MinecraftClient.Protocol.Handlers } break; case PacketIncomingType.MapData: - int mapid = dataTypes.ReadNextVarInt(packetData); - byte scale = dataTypes.ReadNextByte(packetData); - bool trackingposition = dataTypes.ReadNextBool(packetData); - bool locked = false; - if (protocolversion >= MC114Version) - { - locked = dataTypes.ReadNextBool(packetData); - } - int iconcount = dataTypes.ReadNextVarInt(packetData); - handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); - break; + int mapid = dataTypes.ReadNextVarInt(packetData); + byte scale = dataTypes.ReadNextByte(packetData); + bool trackingposition = dataTypes.ReadNextBool(packetData); + bool locked = false; + if (protocolversion >= MC114Version) + { + locked = dataTypes.ReadNextBool(packetData); + } + int iconcount = dataTypes.ReadNextVarInt(packetData); + handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); + break; case PacketIncomingType.Title: if (protocolversion >= MC18Version) {