Mineflayer简介 您所在的位置:网站首页 javascript机器人 Mineflayer简介

Mineflayer简介

2023-08-15 14:20| 来源: 网络整理| 查看: 265

简介

Mineflayer是 PrismarineJS community 创建的开源项目. Mineflayer Github: https://github.com/PrismarineJS/mineflayer PrismarineJS Organization Github: https://github.com/PrismarineJS 使用强大、稳定、高级 JavaScript API 创建 Minecraft机器人。

我是在 YouTube 上偶然看到TheDudeFromCI的视频的,我这几年一直想找类似的API但是居然没找到(可见国内这项目有多凉) 我就很兴奋地搬了几个教程,但是貌似国内并没有什么人知道。 我希望能起到抛砖引玉之效,让大家多了解一下这个有用的项目 如果你看得懂英文,推荐去官方手册看看https://mineflayer.prismarine.js.org

以下为 README 文件的截取内容和部分翻译

Features 支持 Minecraft 1.8、 1.9、 1.10、 1.11、 1.12、 1.13、 1.14、 1.15 和 1.16。实体信息和跟踪。方块信息。你可以查询你周围的世界。在毫秒内查找任何方块。物理和运动 - 处理所有碰撞箱攻击实体和使用车辆。背包管理。合成,箱子,发射器,附魔台。挖掘和放置方块。其他的东西,如知道你的血量,是否下雨。激活方块和使用物品。聊天。 安装

npm install mineflayer

使用

Videos

机器人的基础设置过程

【熟肉】Mineflayer教程 ep.1 快速上手

想进一步学习,这里有更多教程 这里是对应的源代码

开始上手

如果不指定版本,将自动检测服务器的版本,您可以使用版本选项设置特定版本。例如 , version:"1.8"

Echo 例子 const mineflayer = require('mineflayer') const bot = mineflayer.createBot({ host: 'localhost', // optional port: 25565, // optional username: '[email protected]', // email and password are required only for password: '12345678', // online-mode=true servers version: false // false corresponds to auto version detection (that's the default), put for example "1.8.8" if you need a specific version }) bot.on('chat', function (username, message) { if (username === bot.username) return bot.chat(message) }) // Log errors and kick reasons: bot.on('kicked', (reason, loggedIn) => console.log(reason, loggedIn)) bot.on('error', err => console.log(err)) 看看机器人在做什么

得益于prismarine-viewer 项目,你可以在浏览器窗口中显示您的机器人正在做什么。只需运行并将此添加到您的机器人:npm install prismarine-viewer

const mineflayerViewer = require('prismarine-viewer').mineflayer bot.once('spawn', () => { mineflayerViewer(bot, { port: 3007, firstPerson: true }) })

你会得到一个像这样的 实时 视图

viewer

更多例子 例子介绍viewer在浏览器里显示你的机器人的视图pathfinder让机器人自动前往某个地方chest使用箱子、熔炉、发射器、附魔台digger学习怎样创造一个能挖方块的机器人discord用Mineflayer机器人链接Discord机器人jumper学习怎样移动、跳跃、使用载具、攻击附近实体

还有 例子目录 下的许多个

模块

A lot of the active development is happening inside of small npm packages which are used by mineflayer. Mineflayer使用的许多小 npm 包在进行活跃的开发

The Node Way™

“When applications are done well, they are just the really application-specific, brackish residue that can’t be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons.” — substack from “how I write modules”

Modules

Mineflayer的主要组成模块 :

moduledescriptionminecraft-protocolParse and serialize minecraft packets, plus authentication and encryption.minecraft-dataLanguage independent module providing minecraft data for minecraft clients, servers and libraries.prismarine-physicsProvide the physics engine for minecraft entitiesprismarine-chunkA class to hold chunk data for Minecraftnode-vec33d vector math with robust unit testsprismarine-blockRepresent a minecraft block with its associated dataprismarine-chatA parser for a minecraft chat message (extracted from mineflayer)node-yggdrasilNode.js library to interact with Mojang’s authentication system, known as Yggdrasilprismarine-worldThe core implementation of worlds for prismarineprismarine-windowsRepresent minecraft windowsprismarine-itemRepresent a minecraft item with its associated dataprismarine-nbtAn NBT parser for node-minecraft-protocolprismarine-recipeRepresent minecraft recipesprismarine-biomeRepresent a minecraft biome with its associated dataprismarine-entityRepresent a minecraft entity Debug

你可以使用 DEBUG 环境变量来启用一些协议调试输出 :

DEBUG="minecraft-protocol" node [...]

Windows :

set DEBUG=minecraft-protocol node your_script.js 第三方插件

Mineflayer 可以扩展; 任何人都可以创造插件,在Mineflayer基础上添加更高级的API

最有用、最常更新的如下 :

pathfinder - 有很多可自定义功能的A*寻路prismarine-viewer - 简单的网页区块显示器web-inventory - 网页版背包statemachine - 状态机API,给机器人更复杂的行为Armor Manager - 自动装备管理Collect Block - 简单快捷的方块收集APIDashboard - Mineflayer机器人的面板PVP - 简单的PVP/PVE API.auto-eat - 自动吃饭Tool - 自动切换工具武器Hawkeye - 自动用弓瞄准

另见:

navigate - 用A*寻路探索周边 YouTube Demoradar - 用canvas 和socket.io.实现的网页版雷达界面 YouTube Demoblockfinder - 在三维世界里查找方块scaffold - 即使需要破坏、放置方块也能到达目的地 YouTube Demoauto-auth - 聊天栏验证Bloodhound - 判断是什么伤害了实体tps - 获取 tps (processed tps) Projects Using Mineflayer rom1504/rbot YouTube - building a spiral staircaseYouTube - replicating a building Darthfett/Helperbotvogonistic/voxel - visualize what the bot is up to using voxel.jsJonnyD/Skynet - log player activity onto an online APIMinecraftChat (last open source version, built by AlexKvazos) - Minecraft web based chat client https://minecraftchat.net/Cheese Bot - Plugin based bot with a clean GUI. Made with Node-Webkit. http://bot.ezcha.net/Chaoscraft - Minecraft bot using genetic algorithms, see its youtube videoshexatester/minetelegram - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.ProZedd/mineflayer-printer - Prints minecraft schematicsand hundreds more - All the projects that github detected are using mineflayer

使用 MIT 许可证



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有