一个功能强大的基于 Node.js 和 mineflayer 的 Minecraft AI 机器人,支持多账户管理、自动登录、玩家追踪、Web 控制面板和 AI 聊天功能。
- 多账户管理 - 支持管理多个机器人账户,可随时切换
- 自动登录/注册 - 自动检测并执行服务器登录/注册命令
- 玩家追踪 - 实时追踪在线玩家,支持上线/下线提醒
- 自动重连 - 连接断开时自动重连,可配置重试次数和延迟
- Web 控制面板 - 实时查看聊天、玩家列表、背包信息,支持远程控制
- AI 聊天 - 集成多种AI平台(OpenAI、Claude、Gemini、Ollama等),实现智能对话
- 物品管理 - 支持丢弃物品、查看背包等操作
- 命令系统 - 支持多种游戏内命令和 Web 命令
- Node.js 16.0 或更高版本
- npm 或 yarn
- Minecraft 服务器(支持 1.18.2 - 1.21.1 等多个版本)
git clone https://github.com/LzdqesjG/StarBotMC.git
cd StarBotMCnpm install复制配置模板:
copy config_template.json config.json编辑 config.json 文件,填入你的配置信息。
请一定要更改配置文件,否则无法使用
Windows:
npm start或使用启动脚本:
start.batLinux/Mac:
npm start或使用启动脚本:
bash start.sh{
"server": {
"version": "1.21.11",
"host": "jackal.wormwake.com",
"port": 25565
},
"player": {
"username": "YourBotName",
"owner": "YourUsername"
}
}server.version- Minecraft 服务器版本server.host- 服务器 IP 地址或域名server.port- 服务器端口(默认 25565)player.username- 机器人用户名player.owner- 所有者用户名(用于权限验证)
{
"accounts": [
{
"username": "Bot1",
"owner": "YourUsername"
},
{
"username": "Bot2",
"owner": "YourUsername"
}
],
"currentAccountIndex": 0
}accounts- 账户列表currentAccountIndex- 当前使用的账户索引(从 0 开始)
{
"auth": {
"autoLogin": true,
"autoRegister": true,
"password": "your_password_here",
"loginCommand": "/login",
"registerCommand": "/register"
}
}autoLogin- 是否自动登录autoRegister- 是否自动注册password- 登录/注册密码loginCommand- 登录命令(默认 /login)registerCommand- 注册命令(默认 /register)
{
"reconnect": {
"enabled": true,
"maxReconnectAttempts": 10,
"reconnectDelay": 5000
}
}enabled- 是否启用自动重连maxReconnectAttempts- 最大重连尝试次数reconnectDelay- 重连延迟(毫秒)
{
"playerCheckInterval": 10000,
"playerAlerts": {
"YourUsername": {
"message": "欢迎主人上线!",
"leaveMessage": "再见!",
"command": "/tell YourUsername 我在线了!",
"delay": 2000
}
}
}playerCheckInterval- 玩家检查间隔(毫秒)playerAlerts- 特定玩家的提醒配置message- 上线消息leaveMessage- 下线消息command- 执行的命令delay- 延迟执行时间(毫秒)
{
"ai": {
"defaultPlatform": "openai",
"openai": {
"apiUrl": "https://api.openai.com/v1/chat/completions",
"model": "gpt-3.5-turbo",
"apiKey": "your_openai_api_key_here"
},
"claude": {
"apiUrl": "https://api.anthropic.com/v1/messages",
"model": "claude-3-sonnet-20240229",
"apiKey": "your_claude_api_key_here"
},
"gemini": {
"apiUrl": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent",
"model": "gemini-pro",
"apiKey": "your_gemini_api_key_here"
},
"ollama": {
"apiUrl": "http://localhost:11434/api/chat",
"model": "llama2",
"apiKey": "ollama"
},
"qwen": {
"apiUrl": "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation",
"model": "qwen-max",
"apiKey": "your_qwen_api_key_here"
},
"moonshot": {
"apiUrl": "https://api.moonshot.cn/v1/chat/completions",
"model": "moonshot-v1-8k",
"apiKey": "your_moonshot_api_key_here"
},
"zhipu": {
"apiUrl": "https://open.bigmodel.cn/api/paas/v4/chat/completions",
"model": "glm-4",
"apiKey": "your_zhipu_api_key_here"
},
"baichuan": {
"apiUrl": "https://api.baichuan-ai.com/v1/chat/completions",
"model": "Baichuan2-Turbo",
"apiKey": "your_baichuan_api_key_here"
},
"minimax": {
"apiUrl": "https://api.minimaxi.chat/v1/text/chatcompletion_pro",
"model": "abab5.5-chat",
"apiKey": "your_minimax_api_key_here"
}
}
}defaultPlatform- 默认AI平台(可选:openai, claude, gemini, ollama, qwen, moonshot, zhipu, baichuan, minimax)- 各平台配置:
apiUrl- API 地址model- 使用的模型apiKey- API 密钥
获取 API 密钥:
- OpenAI: 访问 OpenAI 官网
- Claude: 访问 Anthropic 官网
- Gemini: 访问 Google AI Studio
- Ollama: 本地运行 Ollama 服务
- 通义千问: 访问 阿里云
- 月之暗面: 访问 Moonshot AI
- 智谱AI: 访问 Zhipu AI
- 百川AI: 访问 Baichuan AI
- MiniMax: 访问 MiniMax
{
"web": {
"password": "your_web_password_here",
"port": 3081,
"host": "0.0.0.0"
}
}password- Web 控制面板登录密码port- web控制台端口host- 监听的IP(默认监听所有ip即0.0.0.0)
{
"startupCommands": [
"/login your_password_here",
"/signin"
],
"signin": {
"enabled": true,
"command": "/signin"
}
}startupCommands- 启动后自动执行的命令列表signin- 自动签到配置
只有所有者(配置文件中的 owner)可以执行以下命令:
!follow- 开始跟随说话的玩家!stop- 停止跟随!ai- 启用 AI 功能!switch- 切换到下一个账户!accounts- 列出所有账户
启动机器人后,在浏览器中访问:
127.0.0.1:web.port
或
localhost:web.port (web.port为配置文件里的值,默认25560)