日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mineflayer简介——Minecraft机器人

發布時間:2023/12/14 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mineflayer简介——Minecraft机器人 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

簡介

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', // optionalport: 25565, // optionalusername: 'email@example.com', // email and password are required only forpassword: '12345678', // online-mode=true serversversion: 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) returnbot.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在瀏覽器里顯示你的機器人的視圖
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的主要組成模塊 :

moduledescription
minecraft-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 entities
prismarine-chunkA class to hold chunk data for Minecraft
node-vec33d vector math with robust unit tests
prismarine-blockRepresent a minecraft block with its associated data
prismarine-chatA parser for a minecraft chat message (extracted from mineflayer)
node-yggdrasilNode.js library to interact with Mojang’s authentication system, known as Yggdrasil
prismarine-worldThe core implementation of worlds for prismarine
prismarine-windowsRepresent minecraft windows
prismarine-itemRepresent a minecraft item with its associated data
prismarine-nbtAn NBT parser for node-minecraft-protocol
prismarine-recipeRepresent minecraft recipes
prismarine-biomeRepresent a minecraft biome with its associated data
prismarine-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 - 簡單快捷的方塊收集API
  • Dashboard - Mineflayer機器人的面板
  • PVP - 簡單的PVP/PVE API.
  • auto-eat - 自動吃飯
  • Tool - 自動切換工具武器
  • Hawkeye - 自動用弓瞄準

另見:

  • navigate - 用A*尋路探索周邊 YouTube Demo
  • radar - 用canvas 和socket.io.實現的網頁版雷達界面 YouTube Demo
  • blockfinder - 在三維世界里查找方塊
  • scaffold - 即使需要破壞、放置方塊也能到達目的地
    YouTube Demo
  • auto-auth - 聊天欄驗證
  • Bloodhound - 判斷是什么傷害了實體
  • tps - 獲取 tps (processed tps)

Projects Using Mineflayer

  • rom1504/rbot
    • YouTube - building a spiral staircase
    • YouTube - replicating a building
  • Darthfett/Helperbot
  • vogonistic/voxel - visualize what
    the bot is up to using voxel.js
  • JonnyD/Skynet - log player activity onto an online API
  • MinecraftChat (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 videos
  • hexatester/minetelegram - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.
  • ProZedd/mineflayer-printer - Prints minecraft schematics
  • and hundreds more - All the projects that github detected are using mineflayer

使用 MIT 許可證

總結

以上是生活随笔為你收集整理的Mineflayer简介——Minecraft机器人的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。