mineflayer 3.14.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +3 -0
- package/.github/workflows/ci.yml +2 -0
- package/README.md +11 -6
- package/docs/FAQ.md +10 -2
- package/docs/README.md +11 -6
- package/docs/api.md +8 -0
- package/docs/history.md +16 -0
- package/docs/zh/CONTRIBUTING.md +93 -0
- package/docs/zh/FAQ.md +169 -0
- package/docs/zh/README_ZH_CN.md +32 -25
- package/docs/zh/_sidebar.md +9 -0
- package/docs/zh/api.md +2132 -0
- package/docs/zh/demos.md +18 -0
- package/docs/zh/history.md +914 -0
- package/docs/zh/index.html +38 -0
- package/docs/zh/tutorial.md +718 -0
- package/examples/anvil.js +10 -12
- package/examples/attack.js +45 -0
- package/examples/chest.js +14 -16
- package/examples/digger.js +25 -31
- package/examples/inventory.js +10 -12
- package/index.d.ts +19 -8
- package/lib/features.json +42 -27
- package/lib/loader.js +1 -1
- package/lib/plugins/blocks.js +70 -90
- package/lib/plugins/chat.js +12 -1
- package/lib/plugins/digging.js +12 -2
- package/lib/plugins/entities.js +11 -4
- package/lib/plugins/game.js +6 -1
- package/lib/promise_utils.js +16 -3
- package/lib/version.js +2 -2
- package/package.json +5 -5
package/.github/FUNDING.yml
CHANGED
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/mineflayer)
|
|
4
4
|
[](https://github.com/PrismarineJS/mineflayer/actions?query=workflow%3A%22CI%22)
|
|
5
|
-
[](https://discord.gg/GsEFRM8)
|
|
6
|
-
[](https://issuehunt.io/r/PrismarineJS/mineflayer)
|
|
7
5
|
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
8
6
|
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
7
|
+
[](https://github.com/sponsors/PrismarineJS)
|
|
8
|
+
|
|
9
|
+
[](https://discord.gg/GsEFRM8)
|
|
9
10
|
|
|
10
11
|
| <sub>EN</sub> [English](README.md) | <sub>RU</sub> [русский](ru/README_RU.md) | <sub>ES</sub> [Español](es/README_ES.md) | <sub>FR</sub> [Français](fr/README_FR.md) | <sub>TR</sub> [Türkçe](tr/README_TR.md) | <sub>ZH</sub> [中文](zh/README_ZH_CN.md) |
|
|
11
12
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
@@ -16,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
16
17
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
19
|
-
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16 and 1.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
20
21
|
* Entity knowledge and tracking.
|
|
21
22
|
* Block knowledge. You can query the world around you. Milliseconds to find any block.
|
|
22
23
|
* Physics and movement - handle all bounding boxes
|
|
@@ -31,7 +32,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
31
32
|
### Roadmap
|
|
32
33
|
|
|
33
34
|
Checkout [this page](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects) to see what our current projects are.
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
## Installation
|
|
36
37
|
|
|
37
38
|
First install Node.js >= 14 from [nodejs.org](https://nodejs.org/) then:
|
|
@@ -230,10 +231,14 @@ The most updated and useful are :
|
|
|
230
231
|
Simply run: `npm test`
|
|
231
232
|
|
|
232
233
|
### Testing specific version
|
|
233
|
-
Run `npm mocha_test -- -g <version>`, where `<version>` is a minecraft version like `1.12`, `1.15.2`...
|
|
234
|
+
Run `npm run mocha_test -- -g <version>`, where `<version>` is a minecraft version like `1.12`, `1.15.2`...
|
|
234
235
|
|
|
235
236
|
### Testing specific test
|
|
236
|
-
Run `npm mocha_test -- -g <test_name>`, where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
|
|
237
|
+
Run `npm run mocha_test -- -g <test_name>`, where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
|
|
238
|
+
|
|
239
|
+
### Example
|
|
240
|
+
|
|
241
|
+
`npm run mocha_test -- -g "1.18.1.*BlockFinder"` to run the block finder test for 1.18.1
|
|
237
242
|
|
|
238
243
|
## License
|
|
239
244
|
|
package/docs/FAQ.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This Frequently Asked Question document is meant to help people for the most common things.
|
|
4
4
|
|
|
5
|
+
### I get an error when trying to login with a microsoft account.
|
|
6
|
+
|
|
7
|
+
Make sure the email you entered into the username option in createBot can be used to login to `minecraft.net` using the 'Login with Microsoft' button.
|
|
8
|
+
Make sure you have the option `auth: 'microsoft'` in your createBot options.
|
|
9
|
+
|
|
10
|
+
When you get an error that says something about invalid credentials or 'Does this account own Minecraft?' try removing the password field in the `createBot` options and try again.
|
|
11
|
+
|
|
5
12
|
### How to hide errors ?
|
|
6
13
|
|
|
7
14
|
Use `hideErrors: true` in createBot options
|
|
@@ -119,7 +126,7 @@ Note that the order in which plugins are loaded is dynamic, so you should never
|
|
|
119
126
|
|
|
120
127
|
### How can I use a socks5 proxy?
|
|
121
128
|
|
|
122
|
-
In the options object for `mineflayer.createBot(options)`, remove your `host` option from the options object, have the following variables declared `PROXY_IP, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD,
|
|
129
|
+
In the options object for `mineflayer.createBot(options)`, remove your `host` option from the options object, have the following variables declared `PROXY_IP, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD, MC_SERVER_ADDRESS, MC_SERVER_PORT` and add this to your options object:
|
|
123
130
|
```js
|
|
124
131
|
connect: (client) => {
|
|
125
132
|
socks.createConnection({
|
|
@@ -132,7 +139,7 @@ connect: (client) => {
|
|
|
132
139
|
},
|
|
133
140
|
command: 'connect',
|
|
134
141
|
destination: {
|
|
135
|
-
host:
|
|
142
|
+
host: MC_SERVER_ADDRESS,
|
|
136
143
|
port: MC_SERVER_PORT
|
|
137
144
|
}
|
|
138
145
|
}, (err, info) => {
|
|
@@ -146,6 +153,7 @@ connect: (client) => {
|
|
|
146
153
|
}
|
|
147
154
|
```
|
|
148
155
|
`socks` is declared with `const socks = require('socks').SocksClient` and uses [this](https://www.npmjs.com/package/socks) package.
|
|
156
|
+
Some servers might reject the connection. If that happens try adding `fakeHost: MC_SERVER_ADDRESS` to your createBot options.
|
|
149
157
|
|
|
150
158
|
# Common Errors
|
|
151
159
|
|
package/docs/README.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/mineflayer)
|
|
4
4
|
[](https://github.com/PrismarineJS/mineflayer/actions?query=workflow%3A%22CI%22)
|
|
5
|
-
[](https://discord.gg/GsEFRM8)
|
|
6
|
-
[](https://issuehunt.io/r/PrismarineJS/mineflayer)
|
|
7
5
|
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
8
6
|
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
7
|
+
[](https://github.com/sponsors/PrismarineJS)
|
|
8
|
+
|
|
9
|
+
[](https://discord.gg/GsEFRM8)
|
|
9
10
|
|
|
10
11
|
| <sub>EN</sub> [English](README.md) | <sub>RU</sub> [русский](ru/README_RU.md) | <sub>ES</sub> [Español](es/README_ES.md) | <sub>FR</sub> [Français](fr/README_FR.md) | <sub>TR</sub> [Türkçe](tr/README_TR.md) | <sub>ZH</sub> [中文](zh/README_ZH_CN.md) |
|
|
11
12
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
@@ -16,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
16
17
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
19
|
-
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16 and 1.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
20
21
|
* Entity knowledge and tracking.
|
|
21
22
|
* Block knowledge. You can query the world around you. Milliseconds to find any block.
|
|
22
23
|
* Physics and movement - handle all bounding boxes
|
|
@@ -31,7 +32,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
31
32
|
### Roadmap
|
|
32
33
|
|
|
33
34
|
Checkout [this page](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects) to see what our current projects are.
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
## Installation
|
|
36
37
|
|
|
37
38
|
First install Node.js >= 14 from [nodejs.org](https://nodejs.org/) then:
|
|
@@ -230,10 +231,14 @@ The most updated and useful are :
|
|
|
230
231
|
Simply run: `npm test`
|
|
231
232
|
|
|
232
233
|
### Testing specific version
|
|
233
|
-
Run `npm mocha_test -- -g <version>`, where `<version>` is a minecraft version like `1.12`, `1.15.2`...
|
|
234
|
+
Run `npm run mocha_test -- -g <version>`, where `<version>` is a minecraft version like `1.12`, `1.15.2`...
|
|
234
235
|
|
|
235
236
|
### Testing specific test
|
|
236
|
-
Run `npm mocha_test -- -g <test_name>`, where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
|
|
237
|
+
Run `npm run mocha_test -- -g <test_name>`, where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
|
|
238
|
+
|
|
239
|
+
### Example
|
|
240
|
+
|
|
241
|
+
`npm run mocha_test -- -g "1.18.1.*BlockFinder"` to run the block finder test for 1.18.1
|
|
237
242
|
|
|
238
243
|
## License
|
|
239
244
|
|
package/docs/api.md
CHANGED
|
@@ -818,6 +818,14 @@ Whether the bot is using the item that it's holding, for example eating food or
|
|
|
818
818
|
|
|
819
819
|
#### bot.game.serverBrand
|
|
820
820
|
|
|
821
|
+
#### bot.game.minY
|
|
822
|
+
|
|
823
|
+
minimum y of the world
|
|
824
|
+
|
|
825
|
+
#### bot.game.height
|
|
826
|
+
|
|
827
|
+
world height
|
|
828
|
+
|
|
821
829
|
### bot.physicsEnabled
|
|
822
830
|
|
|
823
831
|
Enable physics, default true.
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 3.17.0
|
|
2
|
+
|
|
3
|
+
* callback are now depreciated with mineflayer. Any use of them will print a warning
|
|
4
|
+
|
|
5
|
+
## 3.16.0
|
|
6
|
+
|
|
7
|
+
* Use prismarine-chunk for block entities
|
|
8
|
+
|
|
9
|
+
## 3.15.0
|
|
10
|
+
|
|
11
|
+
* Supports 1.18
|
|
12
|
+
|
|
13
|
+
## 3.14.1
|
|
14
|
+
|
|
15
|
+
* Fix arm_animation and use_entity (@amorashi)
|
|
16
|
+
|
|
1
17
|
## 3.14.0
|
|
2
18
|
|
|
3
19
|
* Make prismarine-entity versioned (@u9g)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 贡献
|
|
2
|
+
|
|
3
|
+
Mineflayer 最初主要是由 [andrewrk](http://github.com/andrewrk) 制作的
|
|
4
|
+
但自那以后,许多[贡献者](https://github.com/andrewrk/mineflayer/graphs/contributors)对其进行了改进和修复
|
|
5
|
+
所以知道如何为mineflayer做出贡献的最佳方式很重要
|
|
6
|
+
|
|
7
|
+
## Issue organization
|
|
8
|
+
|
|
9
|
+
我们有3个阶段标签来尝试组织Issue:
|
|
10
|
+
|
|
11
|
+
* Stage 1: 只是由项目新手创建的,我们还不知道它是否值得实现/修复
|
|
12
|
+
* Stage 2: 有希望的想法,但在实施前需要更多思考
|
|
13
|
+
* Stage 3: 想法被精确地指定了,就剩写代码了
|
|
14
|
+
|
|
15
|
+
链接如 https://github.com/PrismarineJS/mineflayer/issues?q=is%3Aopen+is%3Aissue+-label%3AStage1 can be used to filter out stage 1 if you're looking for things that are ready for contribution
|
|
16
|
+
|
|
17
|
+
## 创建测试
|
|
18
|
+
Mineflayer 有两种测试 :
|
|
19
|
+
|
|
20
|
+
* [internal tests](test/internalTest.js) : 针对使用node-minecraft-protocol创建的简单服务器进行的测试
|
|
21
|
+
* [external tests](test/externalTests/) : 针对原版服务器进行的测试
|
|
22
|
+
|
|
23
|
+
The objective of these tests is to know automatically what works and what doesn't in mineflayer, so it's easier to make mineflayer work.
|
|
24
|
+
|
|
25
|
+
### 创建外部测试
|
|
26
|
+
|
|
27
|
+
In order to add an external test now you only need to create a file in [test/externalTests](test/externalTests)
|
|
28
|
+
|
|
29
|
+
一个例子 : [test/externalTests/digAndBuild.js](https://github.com/PrismarineJS/mineflayer/blob/master/test/externalTests/digAndBuild.js)
|
|
30
|
+
|
|
31
|
+
That file needs to export a function returning a function or an array of function taking as parameter the bot object and a done callback,
|
|
32
|
+
it should contain asserts to test if the tested functionality failed.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## 创建第三方插件
|
|
36
|
+
Mineflayer 是可扩展的插件化的; 任何人都可以创建一个插件,在 Mineflayer 之上添加更高级别的 API。
|
|
37
|
+
|
|
38
|
+
已经开发了几个这样的第三方插件 [查看](https://github.com/andrewrk/mineflayer#third-party-plugins)
|
|
39
|
+
|
|
40
|
+
为了创建一个新的,您需要 :
|
|
41
|
+
|
|
42
|
+
1. 创建一个新的 repo
|
|
43
|
+
2. 在你的 index.js 文件中, 导出一个接受参数 mineflayer 的 init 函数 ([查看例子](https://github.com/andrewrk/mineflayer-navigate/blob/e24cb6a868ce64ae43bea2d035832c15ed01d301/index.js#L18))
|
|
44
|
+
3. that function returns a inject function taking in argument the bot object ([example](https://github.com/andrewrk/mineflayer-navigate/blob/e24cb6a868ce64ae43bea2d035832c15ed01d301/index.js#L23))
|
|
45
|
+
4. that inject function add functionalities to the bot object ([example](https://github.com/andrewrk/mineflayer-navigate/blob/e24cb6a868ce64ae43bea2d035832c15ed01d301/index.js#L32))
|
|
46
|
+
|
|
47
|
+
Since the mineflayer object is passed in parameter, that new package doesn't need to depend on mineflayer (no mineflayer dependency in the package.json)
|
|
48
|
+
|
|
49
|
+
参考 [全部示例](https://github.com/andrewrk/mineflayer-navigate/tree/e24cb6a868ce64ae43bea2d035832c15ed01d301)
|
|
50
|
+
|
|
51
|
+
## 反馈Bug
|
|
52
|
+
Mineflayer 在大多数情况下都能很好地工作,但有时仍然存在bug.
|
|
53
|
+
|
|
54
|
+
找到一个问题时,最好报告一个提供这些信息的问题 :
|
|
55
|
+
|
|
56
|
+
* 你想做什么 (英语目标)
|
|
57
|
+
* 你尝试过什么 (代码)
|
|
58
|
+
* 发生了什么事
|
|
59
|
+
* 你期望会发生什么
|
|
60
|
+
|
|
61
|
+
## Mineflayer 代码
|
|
62
|
+
提交请求或提交提交时需要考虑的一些事情 :
|
|
63
|
+
|
|
64
|
+
### 错误处理
|
|
65
|
+
在大多数情况下,mineflayer不会让机器人崩溃。即使有些东西失败了,机器人也可以选择另一条路线来达到它的目标。
|
|
66
|
+
|
|
67
|
+
这意味着我们不应该使用 `throw(new Error("error"))` 而是使用node.js约定在回调中传递错误。
|
|
68
|
+
|
|
69
|
+
例如 :
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
function myfunction (param1, callback) {
|
|
73
|
+
// do stuff
|
|
74
|
+
let toDo = 1
|
|
75
|
+
toDo = 2
|
|
76
|
+
if (toDo === 2) { // 一切正常
|
|
77
|
+
callback()
|
|
78
|
+
} else {
|
|
79
|
+
callback(new Error('什么东西出错了'))
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
请参考另一个例子 [mineflayer code](https://github.com/andrewrk/mineflayer/blob/a8736c4ea473cf1a609c5a29046c0cdad006d429/lib/plugins/bed.js#L10)
|
|
85
|
+
|
|
86
|
+
### 更新文档
|
|
87
|
+
docs/api.md 的内容是用doctoc制作的。更新该文件后,应运行 `doctoc docs/api.md` 以更新目录。
|
|
88
|
+
|
|
89
|
+
没有doctoc命令使用下面的命令安装
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
npm install -g doctoc
|
|
93
|
+
```
|
package/docs/zh/FAQ.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
## FAQ
|
|
2
|
+
|
|
3
|
+
本文档旨在帮助人们解决常见问题
|
|
4
|
+
|
|
5
|
+
### 如何隐藏报错 ?
|
|
6
|
+
|
|
7
|
+
在createBot选项中使用`hideErrors:true`
|
|
8
|
+
您也可以选择添加这些监听事件:
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
client.on('error', () => {})
|
|
12
|
+
client.on('end', () => {})
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 我无法在自定义服务器上获取聊天事件,如何解决?
|
|
16
|
+
|
|
17
|
+
Spigot 服务器, 特别是一些插件, 使用的是自定义聊天格式,您需要使用自定义正则表达式/解析器对其进行解析。
|
|
18
|
+
阅读并改编[chat_parsing.js](https://github.com/PrismarineJS/mineflayer/blob/master/examples/chat_parsing.js)使其适用于您的特定聊天插件. 或者阅读 http://mineflayer.prismarine.js.org/#/tutorial?id=custom-chat
|
|
19
|
+
|
|
20
|
+
### 如何用自定义插件在聊天中收集信息 ?
|
|
21
|
+
|
|
22
|
+
大多数定制的Minecraft服务器都有插件支持,很多插件会在聊天中说一些事情. 如果只是一条信息, 最好使用上述解决方案中讨论的解决方案, 但是当这些消息被分成许多小消息时, 另一个选择是使用 `"messagestr"` 事件 因为它允许轻松解析多行消息.
|
|
23
|
+
|
|
24
|
+
**例子:**
|
|
25
|
+
|
|
26
|
+
聊天栏中的信息看起来像:
|
|
27
|
+
```
|
|
28
|
+
(!) U9G has won the /jackpot and received
|
|
29
|
+
$26,418,402,450! They purchased 2,350,000 (76.32%) ticket(s) out of the
|
|
30
|
+
3,079,185 ticket(s) sold!
|
|
31
|
+
```
|
|
32
|
+
```js
|
|
33
|
+
const regex = {
|
|
34
|
+
first: /\(!\) (.+) has won the \/jackpot and received +/,
|
|
35
|
+
second: /\$(.+)! They purchased (.+) \((.+)%\) ticket\(s\) out of the /,
|
|
36
|
+
third: /(.+) ticket\(s\) sold!/
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let jackpot = {}
|
|
40
|
+
bot.on('messagestr', msg => {
|
|
41
|
+
if (regex.first.test(msg)) {
|
|
42
|
+
const username = msg.match(regex.first)[1]
|
|
43
|
+
jackpot.username = username
|
|
44
|
+
} else if (regex.second.test(msg)) {
|
|
45
|
+
const [, moneyWon, boughtTickets, winPercent] = msg.match(regex.second)
|
|
46
|
+
jackpot.moneyWon = parseInt(moneyWon.replace(/,/g, ''))
|
|
47
|
+
jackpot.boughtTickets = parseInt(boughtTickets.replace(/,/g, ''))
|
|
48
|
+
jackpot.winPercent = parseFloat(winPercent)
|
|
49
|
+
} else if (regex.third.test(msg)) {
|
|
50
|
+
const totalTickets = msg.match(regex.third)[1]
|
|
51
|
+
jackpot.totalTickets = parseInt(totalTickets.replace(/,/g, ''))
|
|
52
|
+
onDone(jackpot)
|
|
53
|
+
jackpot = {}
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
### 如何发送命令 ?
|
|
58
|
+
|
|
59
|
+
使用 `bot.chat()`.
|
|
60
|
+
|
|
61
|
+
**例子:**
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
bot.chat('/give @p minecraft:diamond_sword')
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 是否可以使用bot = mineflayer.createbot登录多个帐户 同时分别控制它们 ?
|
|
68
|
+
|
|
69
|
+
通过调用createBot创建不同的bot实例,然后为每个实例执行不同的操作,请参考 multiple.js
|
|
70
|
+
|
|
71
|
+
### 如何让机器人丢出它的全部背包物品?
|
|
72
|
+
|
|
73
|
+
bot.inventory.items() 返回机器人的物品数组. 您可以使用递归函数循环遍历它们,并使用 `bot.toss()`. [点这里](https://gist.github.com/dada513/3d88f772be4224b40f9e5d1787bd63e9) 查看例子
|
|
74
|
+
|
|
75
|
+
### 如何检查发送/接收的数据包 ?
|
|
76
|
+
|
|
77
|
+
启用调试模式 https://github.com/PrismarineJS/mineflayer#debug
|
|
78
|
+
|
|
79
|
+
### 我希望即使在服务器有延迟的情况下也能避免断开连接,如何实现这一点 ?
|
|
80
|
+
|
|
81
|
+
一种方法是增加 [checkTimeoutInterval](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/docs/API.md#mccreateclientoptions) 选项的值(在createBot中设置) (例如 `300*1000` 这是5分钟,而不是默认的30秒). 如果仍然断开连接,可以使用类似于此示例的方法自动重新连接 https://github.com/PrismarineJS/mineflayer/blob/master/examples/reconnector.js
|
|
82
|
+
|
|
83
|
+
### 如何获取物品的 lore / text?
|
|
84
|
+
|
|
85
|
+
你可以使用 `item.nbt` 属性. 此外建议使用 `prismarine-nbt` 库. `nbt.simplify()` 方法可能有用
|
|
86
|
+
|
|
87
|
+
**例子:**
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
function getLore (item) {
|
|
91
|
+
let message = ''
|
|
92
|
+
if (item.nbt == null) return message
|
|
93
|
+
|
|
94
|
+
const nbt = require('prismarine-nbt')
|
|
95
|
+
const ChatMessage = require('prismarine-chat')(bot.version)
|
|
96
|
+
|
|
97
|
+
const data = nbt.simplify(item.nbt)
|
|
98
|
+
const display = data.display
|
|
99
|
+
if (display == null) return message
|
|
100
|
+
|
|
101
|
+
const lore = display.Lore
|
|
102
|
+
if (lore == null) return message
|
|
103
|
+
for (const line of lore) {
|
|
104
|
+
message += new ChatMessage(line).toString()
|
|
105
|
+
message += '\n'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return message
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 如何从控制台发送消息到服务器?
|
|
113
|
+
|
|
114
|
+
您可以使用类似`repl`的库来读取控制台输入的内容并用`bot.chat()`发送它。 你可以在这查看例子 [点这里](https://github.com/PrismarineJS/mineflayer/blob/master/examples/repl.js)
|
|
115
|
+
|
|
116
|
+
### 创建插件时,如何将另一个插件指定为依赖项?
|
|
117
|
+
|
|
118
|
+
在插件的`inject()`函数中,您可以安全地调用`bot.loadPlugin(anotherPlugin)`确保已加载该插件。如果插件之前已经加载,则不会发生任何事情。
|
|
119
|
+
|
|
120
|
+
请注意,加载插件的顺序是动态的, 因此,永远不要在`inject()`函数中调用其他插件.
|
|
121
|
+
|
|
122
|
+
### 如何使用socks5代理?
|
|
123
|
+
|
|
124
|
+
在对象的选项中 `mineflayer.createBot(options)`,从选项对象中删除你的 `host` 选项,声明以下变量 `PROXY_IP, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD, MC_SERVER_IP, MC_SERVER_PORT` 并将其添加到选项对象中:
|
|
125
|
+
```js
|
|
126
|
+
connect: (client) => {
|
|
127
|
+
socks.createConnection({
|
|
128
|
+
proxy: {
|
|
129
|
+
host: PROXY_IP,
|
|
130
|
+
port: PROXY_PORT,
|
|
131
|
+
type: 5,
|
|
132
|
+
userId: PROXY_USERNAME,
|
|
133
|
+
password: PROXY_PASSWORD
|
|
134
|
+
},
|
|
135
|
+
command: 'connect',
|
|
136
|
+
destination: {
|
|
137
|
+
host: MC_SERVER_IP,
|
|
138
|
+
port: MC_SERVER_PORT
|
|
139
|
+
}
|
|
140
|
+
}, (err, info) => {
|
|
141
|
+
if (err) {
|
|
142
|
+
console.log(err)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
client.setSocket(info.socket)
|
|
146
|
+
client.emit('connect')
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
`socks` 用 `const socks = require('socks').SocksClient` 声明 使用的是[这个](https://www.npmjs.com/package/socks) 包.
|
|
151
|
+
|
|
152
|
+
# 常见错误
|
|
153
|
+
|
|
154
|
+
### `UnhandledPromiseRejectionWarning: Error: Failed to read asymmetric key`
|
|
155
|
+
|
|
156
|
+
当你给 mineflayer 设定了错误的服务器版本,或者 mineflayer 检测到错误的服务器版本时会发生这种情况
|
|
157
|
+
|
|
158
|
+
### `TypeError: Cannot read property '?' of undefined`
|
|
159
|
+
|
|
160
|
+
您可能正在尝试在 bot 对象上使用尚不存在的内容,请尝试在 `spawn` 事件之后调用该语句
|
|
161
|
+
|
|
162
|
+
### `SyntaxError: Unexpected token '?'`
|
|
163
|
+
|
|
164
|
+
更新node版本
|
|
165
|
+
|
|
166
|
+
### The bot can't break/place blocks or open chests
|
|
167
|
+
|
|
168
|
+
检查出生点保护是否阻止了机器人的操作
|
|
169
|
+
|
package/docs/zh/README_ZH_CN.md
CHANGED
|
@@ -10,30 +10,29 @@
|
|
|
10
10
|
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
11
11
|
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
12
12
|
|
|
13
|
-
| <sub>EN</sub> [
|
|
13
|
+
| <sub>EN</sub> [English](README.md) | <sub>RU</sub> [русский](ru/README_RU.md) | <sub>ES</sub> [Español](es/README_ES.md) | <sub>FR</sub> [Français](fr/README_FR.md) | <sub>TR</sub> [Türkçe](tr/README_TR.md) | <sub>ZH</sub> [中文](zh/README_ZH_CN.md) |
|
|
14
14
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
15
15
|
|
|
16
16
|
使用强大、稳定、高级的JavaScript [API](../api.md) 来开发Minecraft机器人,同时支持 Python。
|
|
17
17
|
|
|
18
|
-
第一次使用 node.js ?你可以先看看 [使用教程](../tutorial.md) 。了解过 Python?这里有一些 [Python实例](https://github.com/PrismarineJS/mineflayer/tree/master/examples/python)
|
|
18
|
+
第一次使用 node.js ?你可以先看看 [使用教程](../tutorial.md) 。了解过 Python?这里有一些 [Python实例](https://github.com/PrismarineJS/mineflayer/tree/master/examples/python),同时你也可以 [在谷歌Colab中运行Mineflayer](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb) 来体验一下。
|
|
19
19
|
|
|
20
20
|
## 特点
|
|
21
21
|
|
|
22
|
-
* 支持版本:Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15
|
|
23
|
-
* 实体感知与追踪
|
|
24
|
-
* 方块感知,你可以在几毫秒内查找到bot周围的任何方块
|
|
25
|
-
* 物理和运动引擎 - 支持所有的碰撞箱
|
|
26
|
-
*
|
|
27
|
-
* 背包管理
|
|
28
|
-
* 使用工作台、箱子、酿造台、附魔台
|
|
29
|
-
* 挖掘和建造
|
|
30
|
-
*
|
|
31
|
-
* 激活方块和使用物品
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
点击这个页面,看看目前我们有哪些 [实用项目](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects).
|
|
22
|
+
* 支持版本:Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 1.16 1.17,1.18
|
|
23
|
+
* 实体感知与追踪
|
|
24
|
+
* 方块感知,你可以在几毫秒内查找到bot周围的任何方块
|
|
25
|
+
* 物理和运动引擎 - 支持所有的碰撞箱
|
|
26
|
+
* 攻击实体,使用交通工具
|
|
27
|
+
* 背包管理
|
|
28
|
+
* 使用工作台、箱子、酿造台、附魔台
|
|
29
|
+
* 挖掘和建造
|
|
30
|
+
* 各种各样的的信息接口,比如查看你的血量或是否下雨
|
|
31
|
+
* 激活方块和使用物品
|
|
32
|
+
* 进行聊天
|
|
33
|
+
### 路线图
|
|
34
|
+
|
|
35
|
+
[点这里](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects) 看看目前我们有哪些实用的项目
|
|
37
36
|
|
|
38
37
|
## 安装
|
|
39
38
|
|
|
@@ -85,8 +84,8 @@ const bot = mineflayer.createBot({
|
|
|
85
84
|
username: 'email@example.com', // minecraft 用户名
|
|
86
85
|
password: '12345678' // minecraft 密码, 如果你玩的是不需要正版验证的服务器,请注释掉。
|
|
87
86
|
// port: 25565, // 默认使用25565,如果你的服务器端口不是这个请取消注释并填写。
|
|
88
|
-
// version: false, //
|
|
89
|
-
// auth: 'mojang' //
|
|
87
|
+
// version: false, // 如果需要指定使用一个版本或快照时,请取消注释并手动填写(如:"1.8.9 " 或 "1.16.5"),否则会自动设置。
|
|
88
|
+
// auth: 'mojang' // 如果需要使用微软账号登录时,请取消注释,然后将值设置为 'microsoft',否则会自动设置为 'mojang'。
|
|
90
89
|
})
|
|
91
90
|
|
|
92
91
|
bot.on('chat', (username, message) => {
|
|
@@ -178,7 +177,7 @@ node your_script.js
|
|
|
178
177
|
|
|
179
178
|
## 第三方插件
|
|
180
179
|
|
|
181
|
-
Mineflayer
|
|
180
|
+
Mineflayer 支持插件;任何人都可以创建一个插件,在 Mineflayer 之上添加更高级别的 API。
|
|
182
181
|
|
|
183
182
|
最新和最有用的有:
|
|
184
183
|
|
|
@@ -191,8 +190,12 @@ Mineflayer 是可插拔的;任何人都可以创建一个插件,在 Mineflay
|
|
|
191
190
|
* [Dashboard](https://github.com/wvffle/mineflayer-dashboard) - mineflayer bot 的前端仪表板
|
|
192
191
|
* [PVP](https://github.com/TheDudeFromCI/mineflayer-pvp) - 用于基本 PVP 和 PVE 的简单 API
|
|
193
192
|
* [auto-eat](https://github.com/LINKdiscordd/mineflayer-auto-eat) - 自动进食
|
|
194
|
-
* [
|
|
195
|
-
* [
|
|
193
|
+
* [Auto Crystal](https://github.com/link-discord/mineflayer-autocrystal) - 自动放置和破碎结
|
|
194
|
+
* [Tool](https://github.com/TheDudeFromCI/mineflayer-tool) - 一个具有高级API的工具/武器自动选择工具的工具
|
|
195
|
+
* [Hawkeye](https://github.com/sefirosweb/minecraftHawkEye) - 一个使用自动瞄准弓的工具
|
|
196
|
+
* [GUI](https://github.com/firejoust/mineflayer-GUI) - 简化了嵌套箱子GUI窗口的导航和管理
|
|
197
|
+
* [Projectile](https://github.com/firejoust/mineflayer-projectile) - 以投射物为基础的战斗的可配置插件
|
|
198
|
+
|
|
196
199
|
|
|
197
200
|
也可以看看这些 :
|
|
198
201
|
|
|
@@ -203,13 +206,14 @@ Mineflayer 是可插拔的;任何人都可以创建一个插件,在 Mineflay
|
|
|
203
206
|
* [Bloodhound](https://github.com/Nixes/mineflayer-bloodhound) - 确定谁和什么对另一个实体的损害负责
|
|
204
207
|
* [tps](https://github.com/SiebeDW/mineflayer-tps) - 获取当前的 tps(已处理的 tps)
|
|
205
208
|
* [panorama](https://github.com/IceTank/mineflayer-panorama) - 拍摄您的世界的全景图像
|
|
209
|
+
* [player-death-event](https://github.com/tuanzisama/mineflayer-death-event) - 在Mineflayer里监听玩家死亡事件
|
|
206
210
|
|
|
207
211
|
## 正在使用 Mineflayer 的项目
|
|
208
212
|
|
|
209
213
|
* [rom1504/rbot](https://github.com/rom1504/rbot)
|
|
210
|
-
* [YouTube -
|
|
211
|
-
* [YouTube -
|
|
212
|
-
* [Darthfett/Helperbot](https://github.com/Darthfett/Helperbot)
|
|
214
|
+
* [YouTube - 建造旋转楼梯](https://www.youtube.com/watch?v=UM1ZV5200S0)
|
|
215
|
+
* [YouTube - 复制一个建筑](https://www.youtube.com/watch?v=0cQxg9uDnzA)
|
|
216
|
+
* [Darthfett/Helperbot](https://github.com/Darthfett/Helperbot) - 完成一些简单指令
|
|
213
217
|
* [vogonistic/voxel](https://github.com/vogonistic/mineflayer-voxel) - 使用 voxel.js 可视化机器人正在做什么
|
|
214
218
|
* [JonnyD/Skynet](https://github.com/JonnyD/Skynet) - 将玩家活动记录到在线 API 上
|
|
215
219
|
* [MinecraftChat](https://github.com/rom1504/MinecraftChat) (最后一个开源版本,由 AlexKvazos 构建)——基于 Minecraft 网络的聊天客户端 <https://minecraftchat.net/>
|
|
@@ -233,6 +237,9 @@ Mineflayer 是可插拔的;任何人都可以创建一个插件,在 Mineflay
|
|
|
233
237
|
|
|
234
238
|
运行 `npm mocha_test -- -g <test_name>`,其中 `<test_name>` 是测试名称,例如 `bed`, `useChests`, `rayTrace`...
|
|
235
239
|
|
|
240
|
+
### 示例
|
|
241
|
+
|
|
242
|
+
`npm run mocha_test -- -g "1.18.1.*BlockFinder"` 进行1.18.1寻路测试
|
|
236
243
|
## 许可证
|
|
237
244
|
|
|
238
245
|
[MIT](../LICENSE)
|