Open 41125f03cbb208bf opened 3 months ago
debugmessages=true
1.20.4
MinecraftClient-20240713-273-win-x64
The script loads correctly and the ChatBot is available.
The script is not loaded correctly and the MCC reports an error.
No response
- **Here is my script and the error message. Please point me out if there's anything wrong with my script, I'm still learning how to create an ChatBot.** -------- //MCCScript 1.0 //using System; //using System.Collections.Generic; //using System.Linq; //using System.Text; //using System.Text.RegularExpressions; //using System.IO; //using System.Net; //using System.Threading; //using System.Reflection; //using Brigadier.NET; //using Brigadier.NET.Builder; //using Tomlet.Attributes; //using MinecraftClient; //using MinecraftClient.Mapping; //using MinecraftClient.Inventory; //using MinecraftClient.CommandHandler; //using MinecraftClient.CommandHandler.Patch; //using MinecraftClient.Scripting; MCC.LoadBot(new AdvancedCraft()); //MCCScript Extensions // The code and comments above are defining a "Script Metadata" section // Every single chat bot (script) must be a class which extends the ChatBot class. // Your class must be instantiates in the "Script Metadata" section and passed to MCC.LoadBot function. class AdvancedCraft : ChatBot { public const string CommandName = "advancedcraft"; // This method will be called when the script has been initialized for the first time, it's called only once // Here you can initialize variables, eg. Dictionaries. 等... public override void Initialize() { LogToConsole("AdvancedCraft has been initialized!"); McClient.dispatcher.Register(l => l.Literal("help") .Then(l => l.Literal(CommandName) .Executes(r => OnCommandHelp(r.Source, null, null)) .Then(l => l.Literal("recipe") .Executes(r => OnCommandHelp(r.Source, "recipe", null)) .Then(l => l.Literal("list") .Executes(r => OnCommandHelp(r.Source, "recipe", "list"))) .Then(l => l.Literal("reload") .Executes(r => OnCommandHelp(r.Source, "recipe", "reload"))) .Then(l => l.Literal("add") .Executes(r => OnCommandHelp(r.Source, "recipe", "add"))) .Then(l => l.Literal("remove") .Executes(r => OnCommandHelp(r.Source, "recipe", "remove")))) .Then(l => l.Literal("start") .Executes(r => OnCommandHelp(r.Source, "start", null))) .Then(l => l.Literal("stop") .Executes(r => OnCommandHelp(r.Source, "stop", null))) .Then(l => l.Literal("help") .Executes(r => OnCommandHelp(r.Source, "help", null))) ) ); McClient.dispatcher.Register(l => l.Literal(CommandName) .Then(l => l.Literal("recipe") .Then(l => l.Literal("list") .Executes(r => OnCommandListRecipe(r.Source))) .Then(l => l.Literal("reload") .Executes(r => OnCommandReloadRecipe(r.Source))) .Then(l => l.Literal("add") .Then(l => l.Literal("recipwName") .Then(l => l.Literal("recipe") .Executes(r => OnCommandAddRecipe(r.Source, Arguments.GetString(r, "recipeName"), Arguments.GetString(r, "recipe")))))) .Then(l => l.Literal("remove") .Then(l => l.Literal("recipeName") .Executes(r => OnCommandRemoveRecipe(r.Source, Arguments.GetString(r, "recipeName")))))) .Then(l => l.Literal("start") .Then(l => l.Argument("recipeName", MccArguments.AutoCraftRecipeName()) .Executes(r => OnCommandStart(r.Source, Arguments.GetString(r, "recipeName"))) .Then(l => l.Literal("tableLocation") .Executes(r => OnCommandStart(r.Source, Arguments.GetString(r, "recipeName"), MccArguments.GetLocation(r, "tableLocation")))))) .Then(l => l.Literal("stop") .Executes(r => OnCommandStop(r.Source))) .Then(l => l.Literal("_help") .Executes(r => OnCommandHelp(r.Source, null, null)) .Redirect(McClient.dispatcher.GetRoot().GetChild("help").GetChild(CommandName))) ); } public override void OnUnload(){ McClient.dispatcher.Unregister(CommandName); McClient.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName); } private int OnCommandHelp(CmdResult r, string? cmd, string? param) => (cmd, param) switch { //todo #pragma warning disable format // @formatter:off ("recipe", null) => r.SetAndReturn("recipe"), ("recipe", "list") => r.SetAndReturn("recipe list"), ("recipe", "reload") => r.SetAndReturn("recipe reload"), ("recipe", "add") => r.SetAndReturn("recipe add"), ("recipe", "remove") => r.SetAndReturn("recipe remove"), ("start", null) => r.SetAndReturn("start"), ("stop", null) => r.SetAndReturn("stop"), ("help", null) => r.SetAndReturn("help"), _ => r.SetAndReturn("error") #pragma warning restore format // @formatter:on }; private int OnCommandListRecipe(CmdResult r) { //todo return r.SetAndReturn("ListRecipe"); } private int OnCommandReloadRecipe(CmdResult r) { //todo return r.SetAndReturn("ReloadRecipe"); } private int OnCommandAddRecipe(CmdResult r, string RecipeName, string Recipe) { //todo return r.SetAndReturn("AddRecipe"); } private int OnCommandRemoveRecipe(CmdResult r, string RecipeName) { //todo return r.SetAndReturn("RemoveRecipe"); } private int OnCommandStart(CmdResult r, string RecipeName) { //todo return r.SetAndReturn("Start"); } private int OnCommandStart(CmdResult r, string RecipeName, Location tableLocation) { //todo return r.SetAndReturn("Start"); } private int OnCommandStop(CmdResult r) { //todo return r.SetAndReturn("Stop"); } // This is a function that will be run when we get a chat message from a server // In this example it just detects the type of the message and prints it out public override void GetText(string text) { /* string message = ""; string username = ""; text = GetVerbatim(text); if (IsPrivateMessage(text, ref message, ref username)) { LogToConsole(username + " has sent you a private message: " + message); } else if (IsChatMessage(text, ref message, ref username)) { LogToConsole(username + " has said: " + message); } */ } } -------- Minecraft Console Client v1.20.4 - for MC 1.4.6 to 1.20.4 - Github.com/MCCTeam GitHub build 273, built on 2024-07-13 from commit ca966a4 20:07:35 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: False 指定时刻触发: True 指定时间间隔触发: True 时刻触发配置: 14:00:00 间隔触发配置: 53.4 动作: send /hello 20:07:35 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: True 指定时刻触发: False 指定时间间隔触发: False 时刻触发配置: 间隔触发配置: 56 动作: send /login pass 帮助我们翻译MCC:https://crwd.in/minecraft-console-client 20:07:35 颜色测试:终端应该显示:[0123456789ABCDEF]: (4bit)[0123456789ABCDEF] 颜色测试:终端应该显示:[0123456789]: (vt100 8bit)[0123456789] 颜色测试:终端应该显示:[0123456789]: (vt100 24bit)[0123456789] 20:07:35 [SessionCache] 正在为文件E:\MinecraftConsoleClient\LocalTest\SessionCache.ini初始化FileSystemWatcher 20:07:35 加载Minecraft配置文件:launcher_profiles.json 20:07:35 无法从磁盘加载缓存的会话数据。 20:07:35 您正在使用离线模式。 成功!(会话ID:) 20:07:35 正在以 Minecraft 版本 1.20.4 (v765协议)运行 20:07:35 [MCC] [自动重连] 已启动,尝试了2147483647次重新连接 20:07:35 [MCC] [自动重连] 在没有kick消息文件的情况下初始化 20:07:35 已加载翻译文件。 20:07:35 [MCC] 该版本受到支持 正在登录... 20:07:35 [MCC] 服务器正处于离线模式。 20:07:35 [MCC] 已成功加入服务器。 输入 '/quit' 离开服务器。 20:07:35 [DEBUG] Receive JoinGame 20:07:35 [DEBUG] CanSendMessage = True 20:07:35 [DEBUG] Receive DeclareCommands 20:07:35 [DEBUG] Receive ChatUuid = Empty 20:07:35 [DEBUG] CanSendMessage = True 20:07:42 [MCC] [Script] Starting compilation for .\AdvancedCraft.cs... 20:07:44 [MCC] [Script] Compilation failed with error(s): 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal("help")): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal("help")): [CS0012] 类型“Func<,>”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal("help")): [CS1660] 无法将 lambda 表达式 转换为类型“LiteralArgumentBuilder<CmdResult>”,原因是它不是委托类型 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Func<,>”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Register(l => l.Literal(CommandName)): [CS1660] 无法将 lambda 表达式 转换为类型“LiteralArgumentBuilder<CmdResult>”,原因是它不 是委托类型 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.Unregister(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [Script] Error in .\AdvancedCraft.cs, on line (McClient.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:07:44 [MCC] [脚本] 脚本'.\AdvancedCraft.cs'运行失败 (InvalidScript)。 20:07:44 [MCC] [脚本] System.InvalidProgramException: Compilation failed due to error(s). > -------- - **This is the error message when loading the AutoTree.cs.** -------- Minecraft Console Client v1.20.4 - for MC 1.4.6 to 1.20.4 - Github.com/MCCTeam GitHub build 273, built on 2024-07-13 from commit ca966a4 20:19:40 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: False 指定时刻触发: True 指定时间间隔触发: True 时刻触发配置: 14:00:00 间隔触发配置: 53.4 动作: send /hello 20:19:40 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: True 指定时刻触发: False 指定时间间隔触发: False 时刻触发配置: 间隔触发配置: 56 动作: send /login pass 帮助我们翻译MCC:https://crwd.in/minecraft-console-client 20:19:40 颜色测试:终端应该显示:[0123456789ABCDEF]: (4bit)[0123456789ABCDEF] 颜色测试:终端应该显示:[0123456789]: (vt100 8bit)[0123456789] 颜色测试:终端应该显示:[0123456789]: (vt100 24bit)[0123456789] 20:19:40 [SessionCache] 正在为文件E:\MinecraftConsoleClient\LocalTest\SessionCache.ini初始化FileSystemWatcher 20:19:40 加载Minecraft配置文件:launcher_profiles.json 20:19:40 无法从磁盘加载缓存的会话数据。 20:19:40 您正在使用离线模式。 成功!(会话ID:) 20:19:40 正在以 Minecraft 版本 1.20.4 (v765协议)运行 20:19:40 [MCC] [自动重连] 已启动,尝试了2147483647次重新连接 20:19:40 [MCC] [自动重连] 在没有kick消息文件的情况下初始化 20:19:40 已加载翻译文件。 20:19:40 [MCC] 该版本受到支持 正在登录... 20:19:40 [MCC] 服务器正处于离线模式。 20:19:40 [MCC] 已成功加入服务器。 输入 '/quit' 离开服务器。 20:19:40 [DEBUG] Receive JoinGame 20:19:40 [DEBUG] CanSendMessage = True 20:19:40 [DEBUG] Receive DeclareCommands 20:19:40 [DEBUG] Receive ChatUuid = Empty 20:19:40 [DEBUG] CanSendMessage = True 20:19:50 [MCC] [Script] Starting compilation for .\AutoTree.cs... 20:19:51 [MCC] [Script] Compilation failed with error(s): 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (public override void Initialize(CommandDispatcher<CmdResult> dispatcher)): [CS0115] “Script.AutoTree.Initialize(CommandDispatcher<CmdResult>)”: 没有找到适合的方法来重写 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)): [CS0115] “Script.AutoTree.OnUnload(CommandDispatcher<CmdResult>)”: 没有找到适合的方法来重写 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal("help")): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal("help")): [CS0012] 类型“Func<,>”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal("help")): [CS1660] 无法将 lambda 表达式 转换为类型“LiteralArgumentBuilder<CmdResult>”,原因是它不是委托类型 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Func<,>”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Register(l => l.Literal(CommandName)): [CS1660] 无法将 lambda 表达式 转换为类型“LiteralArgumentBuilder<CmdResult>”,原因是它不是委托类型 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.Unregister(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [Script] Error in .\AutoTree.cs, on line (+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:19:51 [MCC] [脚本] 脚本'.\AutoTree.cs'运行失败 (InvalidScript)。 20:19:51 [MCC] [脚本] System.InvalidProgramException: Compilation failed due to error(s). > -------- - **This is the error message when loading the MineCube.cs.** -------- Minecraft Console Client v1.20.4 - for MC 1.4.6 to 1.20.4 - Github.com/MCCTeam GitHub build 273, built on 2024-07-13 from commit ca966a4 20:22:19 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: False 指定时刻触发: True 指定时间间隔触发: True 时刻触发配置: 14:00:00 间隔触发配置: 53.4 动作: send /hello 20:22:19 [MCC] [ScriptScheduler] 已加载任务: 首次登录时触发: False 登录时触发: True 指定时刻触发: False 指定时间间隔触发: False 时刻触发配置: 间隔触发配置: 56 动作: send /login pass 帮助我们翻译MCC:https://crwd.in/minecraft-console-client 20:22:20 颜色测试:终端应该显示:[0123456789ABCDEF]: (4bit)[0123456789ABCDEF] 颜色测试:终端应该显示:[0123456789]: (vt100 8bit)[0123456789] 颜色测试:终端应该显示:[0123456789]: (vt100 24bit)[0123456789] 20:22:20 [SessionCache] 正在为文件E:\MinecraftConsoleClient\LocalTest\SessionCache.ini初始化FileSystemWatcher 20:22:20 加载Minecraft配置文件:launcher_profiles.json 20:22:20 无法从磁盘加载缓存的会话数据。 20:22:20 您正在使用离线模式。 成功!(会话ID:) 20:22:20 正在以 Minecraft 版本 1.20.4 (v765协议)运行 20:22:20 [MCC] [自动重连] 已启动,尝试了2147483647次重新连接 20:22:20 [MCC] [自动重连] 在没有kick消息文件的情况下初始化 20:22:20 已加载翻译文件。 20:22:20 [MCC] 该版本受到支持 正在登录... 20:22:20 [MCC] 服务器正处于离线模式。 20:22:20 [MCC] 已成功加入服务器。 输入 '/quit' 离开服务器。 20:22:20 [DEBUG] Receive JoinGame 20:22:20 [DEBUG] CanSendMessage = True 20:22:20 [DEBUG] Receive DeclareCommands 20:22:20 [DEBUG] Receive ChatUuid = Empty 20:22:20 [DEBUG] CanSendMessage = True 20:22:33 [MCC] [Script] Starting compilation for .\MineCube.cs... 20:22:34 [MCC] [Script] Compilation failed with error(s): 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (LogToConsole(Translations.extra_terrainandmovement_required);): [CS0122] “Translations”不可访问,因为它具有一定的保护级别 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Register(l => l.Literal(CommandName)): [CS0176] 无法使用实例引用来访问成员“McClient.dispatcher”;请改用类型名来限定它 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Register(l => l.Literal(CommandName)): [CS0012] 类型“Func<,>”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Register(l => l.Literal(CommandName)): [CS1660] 无法将 lambda 表达式 转换为类型“LiteralArgumentBuilder<CmdResult>”,原因是它不是委托 类型 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Unregister(CommandName);): [CS0176] 无法使用实例引用来访问成员“McClient.dispatcher”;请改用类型名来限定它 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (Handler.dispatcher.Unregister(CommandName);): [CS0012] 类型“Object”在未引用的程序集中定义。必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。 20:22:34 [MCC] [Script] Error in .\MineCube.cs, on line (if (mineLocation == currentBlockUnderFeet && !Movement.IsSafe(currentWorld, currentBlockUnderFeet))): [CS0117] “Movement”未包含“IsSafe”的定义 20:22:34 [MCC] [脚本] 脚本'.\MineCube.cs'运行失败 (InvalidScript)。 20:22:34 [MCC] [脚本] System.InvalidProgramException: Compilation failed due to error(s). >
Desktop
Windows
Prerequisites
debugmessages=true
in config to diagnose my issueMinecraft Version
1.20.4
Console Client Version
MinecraftClient-20240713-273-win-x64
Expected Behavior
The script loads correctly and the ChatBot is available.
Actual Behavior
The script is not loaded correctly and the MCC reports an error.
Steps to Reproduce the bug
Attach screenshot here (If applicable)
No response
Anythings that could help diagnosing the bug
Device
Desktop
Operating System
Windows
Server Address (If applicable)
No response