mineflayer 4.35.0 → 4.37.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.
@@ -15,7 +15,7 @@ jobs:
15
15
  - name: Use Node.js 22.x
16
16
  uses: actions/setup-node@v1.4.4
17
17
  with:
18
- node-version: 22.x
18
+ node-version: 24
19
19
  - run: npm i && npm run lint
20
20
 
21
21
  PrepareSupportedVersions:
@@ -28,19 +28,25 @@ jobs:
28
28
  - name: Use Node.js 22.x
29
29
  uses: actions/setup-node@v1.4.4
30
30
  with:
31
- node-version: 22.x
31
+ node-version: 24
32
32
  - id: set-matrix
33
33
  run: |
34
34
  node -e "
35
- const testedVersions = require('./lib/version').testedVersions;
36
- console.log('matrix='+JSON.stringify({'include': testedVersions.map(mcVersion => ({mcVersion}))}))
35
+ const v = require('./lib/version').testedVersions;
36
+ const groups = [];
37
+ const SIZE = 4;
38
+ for (let i = 0; i < v.length; i += SIZE) {
39
+ groups.push({ versions: v.slice(i, i + SIZE).join(' ') });
40
+ }
41
+ console.log('matrix='+JSON.stringify({'include': groups}))
37
42
  " >> $GITHUB_OUTPUT
38
43
 
39
44
  MinecraftServer:
40
45
  needs: PrepareSupportedVersions
41
46
  runs-on: ubuntu-latest
47
+ name: MC ${{ matrix.versions }}
42
48
  strategy:
43
- matrix: ${{fromJson(needs.PrepareSupportedVersions.outputs.matrix)}}
49
+ matrix: ${{ fromJson(needs.PrepareSupportedVersions.outputs.matrix) }}
44
50
  fail-fast: false
45
51
 
46
52
  steps:
@@ -48,7 +54,7 @@ jobs:
48
54
  - name: Use Node.js 22.x
49
55
  uses: actions/setup-node@v1.4.4
50
56
  with:
51
- node-version: 22.x
57
+ node-version: 24
52
58
  - name: Setup Java JDK
53
59
  uses: actions/setup-java@v1.4.3
54
60
  with:
@@ -58,4 +64,33 @@ jobs:
58
64
  run: npm install
59
65
 
60
66
  - name: Start Tests
61
- run: npm run mocha_test -- -g ${{ matrix.mcVersion }}v
67
+ run: |
68
+ exit_code=0
69
+ pids=""
70
+ for v in ${{ matrix.versions }}; do
71
+ npm run mocha_test -- --retries 3 -g "${v}v" > "test-${v}.log" 2>&1 &
72
+ pids="$pids $!"
73
+ done
74
+ for pid in $pids; do
75
+ wait $pid || exit_code=$?
76
+ done
77
+ # Print passing versions first, then failing versions last
78
+ for v in ${{ matrix.versions }}; do
79
+ if ! grep -q "failing" "test-${v}.log"; then
80
+ echo ""
81
+ echo "=========================================="
82
+ echo " Results for Minecraft ${v}"
83
+ echo "=========================================="
84
+ cat "test-${v}.log"
85
+ fi
86
+ done
87
+ for v in ${{ matrix.versions }}; do
88
+ if grep -q "failing" "test-${v}.log"; then
89
+ echo ""
90
+ echo "=========================================="
91
+ echo " FAILED: Minecraft ${v}"
92
+ echo "=========================================="
93
+ cat "test-${v}.log"
94
+ fi
95
+ done
96
+ exit $exit_code
@@ -3,6 +3,9 @@ on:
3
3
  push:
4
4
  branches:
5
5
  - master # Change this to your default branch
6
+ permissions:
7
+ id-token: write
8
+ contents: write
6
9
  jobs:
7
10
  npm-publish:
8
11
  name: npm-publish
@@ -13,13 +16,12 @@ jobs:
13
16
  - name: Set up Node.js
14
17
  uses: actions/setup-node@master
15
18
  with:
16
- node-version: 22.0.0
19
+ node-version: 24
20
+ registry-url: 'https://registry.npmjs.org'
17
21
  - id: publish
18
- uses: JS-DevTools/npm-publish@v1
19
- with:
20
- token: ${{ secrets.NPM_AUTH_TOKEN }}
22
+ uses: JS-DevTools/npm-publish@v4
21
23
  - name: Create Release
22
- if: steps.publish.outputs.type != 'none'
24
+ if: ${{ steps.publish.outputs.type }}
23
25
  id: create_release
24
26
  uses: actions/create-release@v1
25
27
  env:
package/docs/history.md CHANGED
@@ -1,4 +1,19 @@
1
1
  ## 4.35.0
2
+
3
+ ## 4.37.0
4
+ * [CI: print failed version logs last for easy debugging (#3876)](https://github.com/PrismarineJS/mineflayer/commit/56efbcde16343576533eaa7a08e85b785ae847cd) (thanks @rom1504)
5
+ * [Fix nether test reliability and add set_player_inventory handler (#3874)](https://github.com/PrismarineJS/mineflayer/commit/fd03f0a83e00229344b0624ce5ace9e0303599f3) (thanks @rom1504)
6
+ * [Improve test reliability: reconnect, retry, server console, packet fix (#3873)](https://github.com/PrismarineJS/mineflayer/commit/23f60d2132d49c08d936073d215466a825045933) (thanks @rom1504)
7
+ * [Improve test reliability: server console gamemode, retries, NaN guard (#3871)](https://github.com/PrismarineJS/mineflayer/commit/7af5e2ccf2f7ed1240ea792cb425a20e669618c2) (thanks @rom1504)
8
+ * [CI: run 4 MC versions per job to halve runner pressure (#3870)](https://github.com/PrismarineJS/mineflayer/commit/85a164d86e2b8bac996946ef6fb46d800861c82f) (thanks @rom1504)
9
+ * [Speed up tests: remove sleep(1000) in resetState (#3869)](https://github.com/PrismarineJS/mineflayer/commit/81ecd72bafafc711ee2bc32b19d64f2bd897c4fb) (thanks @rom1504)
10
+
11
+ ## 4.36.0
12
+ * [Update CI to Node 24 (#3861)](https://github.com/PrismarineJS/mineflayer/commit/3b05f83d536adb31103c811f7093361ff35449a1) (thanks @rom1504)
13
+ * [Fix publish condition for npm-publish v4 (#3858)](https://github.com/PrismarineJS/mineflayer/commit/ea663478fa1cb4f602735675aebd0c8459c7576d) (thanks @rom1504)
14
+ * [Switch to trusted publishing via OIDC (#3856)](https://github.com/PrismarineJS/mineflayer/commit/3173eeded3982b144bc40d7b0fdfb083ee7eb118) (thanks @rom1504)
15
+ * [Bump @types/node to 25.2.1 + fix flaky time & nether tests (#3828)](https://github.com/PrismarineJS/mineflayer/commit/89686596c8de1091bf45104ba3230a5e87707a20) (thanks @plainprince)
16
+
2
17
  * [🎈 1.21.11 (#3781)](https://github.com/PrismarineJS/mineflayer/commit/597745c7c061943620fcacba7254bccee05b7a3e) (thanks @rom1504bot)
3
18
  * [Fix chat pattern and event listener in tutorial (#3783)](https://github.com/PrismarineJS/mineflayer/commit/48586138f560991de60bea639c71fa82954cf50f) (thanks @brentspine)
4
19
  * [Update history.md](https://github.com/PrismarineJS/mineflayer/commit/c9f766513d5bb5a93c5b86c07827128716c0afdb) (thanks @extremeheat)
@@ -728,6 +728,12 @@ function inject (bot, { hideErrors }) {
728
728
  const newItem = Item.fromNotch(packet.item)
729
729
  bot._setSlot(packet.slot, newItem, window)
730
730
  })
731
+ // 1.21.9+ uses set_player_inventory for server-initiated inventory changes
732
+ // (e.g. console /give) instead of set_slot
733
+ bot._client.on('set_player_inventory', (packet) => {
734
+ const newItem = Item.fromNotch(packet.contents)
735
+ bot._setSlot(packet.slotId, newItem)
736
+ })
731
737
  bot._client.on('window_items', (packet) => {
732
738
  const window = packet.windowId === 0 ? bot.inventory : bot.currentWindow
733
739
  if (!window || window.id !== packet.windowId) {
@@ -76,6 +76,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
76
76
  }
77
77
 
78
78
  function tickPhysics (now) {
79
+ if (!bot.entity?.position || !Number.isFinite(bot.entity.position.x)) return // entity not ready
79
80
  if (bot.blockAt(bot.entity.position) == null) return // check if chunk is unloaded
80
81
  if (bot.physicsEnabled && shouldUsePhysics) {
81
82
  physics.simulatePlayer(new PlayerState(bot, controlState), world).apply(bot)
@@ -99,6 +100,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
99
100
 
100
101
  function sendPacketPosition (position, onGround) {
101
102
  // sends data, no logic
103
+ if (!Number.isFinite(position.x) || !Number.isFinite(position.y) || !Number.isFinite(position.z)) return
102
104
  const oldPos = new Vec3(lastSent.x, lastSent.y, lastSent.z)
103
105
  lastSent.x = position.x
104
106
  lastSent.y = position.y
@@ -122,6 +124,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
122
124
 
123
125
  function sendPacketPositionAndLook (position, yaw, pitch, onGround) {
124
126
  // sends data, no logic
127
+ if (!Number.isFinite(position.x) || !Number.isFinite(position.y) || !Number.isFinite(position.z)) return
125
128
  const oldPos = new Vec3(lastSent.x, lastSent.y, lastSent.z)
126
129
  lastSent.x = position.x
127
130
  lastSent.y = position.y
@@ -153,6 +156,8 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
153
156
  function updatePosition (now) {
154
157
  // Only send updates for 20 ticks after death
155
158
  if (isEntityRemoved()) return
159
+ // Don't send position with invalid coordinates (NaN after death)
160
+ if (!Number.isFinite(bot.entity.position.x)) return
156
161
 
157
162
  // Increment the yaw in baby steps so that notchian clients (not the server) can keep up.
158
163
  const dYaw = deltaYaw(bot.entity.yaw, lastSentYaw)
@@ -415,6 +420,27 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
415
420
  if (bot.supportFeature('teleportUsesOwnPacket')) {
416
421
  bot._client.write('teleport_confirm', { teleportId: packet.teleportId })
417
422
  }
423
+
424
+ // After death/respawn, delay the forced position_look response.
425
+ // Sending it immediately causes "Invalid move player packet" kicks
426
+ // on older servers, but the server needs it to complete the respawn.
427
+ if (respawnTimer > 0 && Date.now() - respawnTimer < 2000) {
428
+ respawnTimer = 0 // only delay once
429
+ const delayedPos = pos.clone()
430
+ const delayedYaw = newYaw
431
+ const delayedPitch = newPitch
432
+ const delayedOnGround = bot.entity.onGround
433
+ setTimeout(() => {
434
+ sendPacketPositionAndLook(delayedPos, delayedYaw, delayedPitch, delayedOnGround)
435
+ shouldUsePhysics = true
436
+ bot.jumpTicks = 0
437
+ lastSentYaw = bot.entity.yaw
438
+ lastSentPitch = bot.entity.pitch
439
+ bot.emit('forcedMove')
440
+ }, 1500)
441
+ return
442
+ }
443
+
418
444
  sendPacketPositionAndLook(pos, newYaw, newPitch, bot.entity.onGround)
419
445
 
420
446
  shouldUsePhysics = true
@@ -447,7 +473,12 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
447
473
  })
448
474
  }
449
475
 
476
+ let respawnTimer = 0
450
477
  bot.on('mount', () => { shouldUsePhysics = false })
478
+ bot.on('death', () => {
479
+ shouldUsePhysics = false
480
+ respawnTimer = Date.now()
481
+ })
451
482
  bot.on('respawn', () => { shouldUsePhysics = false })
452
483
  bot.on('login', () => {
453
484
  shouldUsePhysics = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mineflayer",
3
- "version": "4.35.0",
3
+ "version": "4.37.0",
4
4
  "description": "create minecraft bots with a stable, high level API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "minecraft-data": "^3.98.0",
24
+ "minecraft-data": "^3.108.0",
25
25
  "minecraft-protocol": "^1.64.0",
26
26
  "prismarine-biome": "^1.1.1",
27
27
  "prismarine-block": "^1.22.0",
@@ -31,7 +31,7 @@
31
31
  "prismarine-item": "^1.17.0",
32
32
  "prismarine-nbt": "^2.0.0",
33
33
  "prismarine-physics": "^1.9.0",
34
- "prismarine-recipe": "^1.3.0",
34
+ "prismarine-recipe": "^1.5.0",
35
35
  "prismarine-registry": "^1.10.0",
36
36
  "prismarine-windows": "^2.9.0",
37
37
  "prismarine-world": "^3.6.0",
@@ -41,7 +41,7 @@
41
41
  "vec3": "^0.1.7"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^24.0.6",
44
+ "@types/node": "^25.2.1",
45
45
  "doctoc": "^2.0.1",
46
46
  "minecraft-wrap": "^1.3.0",
47
47
  "mineflayer": "file:",
package/README.md DELETED
@@ -1,292 +0,0 @@
1
- # Mineflayer
2
-
3
- [![NPM version](https://img.shields.io/npm/v/mineflayer.svg?color=success&label=npm%20package&logo=npm)](https://www.npmjs.com/package/mineflayer)
4
- [![Build Status](https://img.shields.io/github/actions/workflow/status/PrismarineJS/mineflayer/ci.yml.svg?label=CI&logo=github&logoColor=lightgrey)](https://github.com/PrismarineJS/mineflayer/actions?query=workflow%3A%22CI%22)
5
- [![Try it on gitpod](https://img.shields.io/static/v1.svg?label=try&message=on%20gitpod&color=brightgreen&logo=gitpod)](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
6
- [![Open In Colab](https://img.shields.io/static/v1.svg?label=open&message=on%20colab&color=blue&logo=google-colab)](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
7
- [![GitHub Sponsors](https://img.shields.io/github/sponsors/PrismarineJS)](https://github.com/sponsors/PrismarineJS)
8
-
9
- [![Official Discord](https://img.shields.io/static/v1.svg?label=OFFICIAL&message=DISCORD&color=blue&logo=discord&style=for-the-badge)](https://discord.gg/GsEFRM8)
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) | <sub>BR</sub> [Português](br/README_BR.md) |
12
- |-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|-------------------------|--------------------|
13
-
14
- Create Minecraft bots with a powerful, stable, and high level JavaScript [API](api.md), also usable from Python.
15
-
16
- First time using Node.js? You may want to start with the [tutorial](tutorial.md). Know Python? Checkout some [Python examples](https://github.com/PrismarineJS/mineflayer/tree/master/examples/python) and try out [Mineflayer on Google Colab](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb).
17
-
18
- ## Features
19
-
20
- * Supports Minecraft 1.8 to 1.21.11 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.21.9, 1.21.11) <!--version-->
21
- * Entity knowledge and tracking.
22
- * Block knowledge. You can query the world around you. Milliseconds to find any block.
23
- * Physics and movement - handle all bounding boxes
24
- * Attacking entities and using vehicles.
25
- * Inventory management.
26
- * Crafting, chests, dispensers, enchantment tables.
27
- * Digging and building.
28
- * Miscellaneous stuff such as knowing your health and whether it is raining.
29
- * Activating blocks and using items.
30
- * Chat.
31
-
32
- ### Roadmap
33
-
34
- Checkout [this page](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects) to see what our current projects are.
35
-
36
- ## Installation
37
-
38
- First install Node.js >= 18 from [nodejs.org](https://nodejs.org/) then:
39
-
40
- ```bash
41
- npm install mineflayer
42
- ```
43
-
44
- To update mineflayer (or any Node.js) package and its dependencies, use
45
- ```bash
46
- npm update
47
- ```
48
-
49
- ## Documentation
50
-
51
- | link | description |
52
- |---|---|
53
- |[tutorial](tutorial.md) | Begin with Node.js and mineflayer |
54
- | [FAQ.md](FAQ.md) | Got a question ? go there first |
55
- | **[api.md](api.md)** <br/>[unstable_api.md](unstable_api.md) | The full API reference |
56
- | [history.md](history.md) | The changelog for mineflayer |
57
- | [examples/](https://github.com/PrismarineJS/mineflayer/tree/master/examples) | Checkout all the mineflayer examples |
58
-
59
-
60
- ## Contribute
61
-
62
- Please read [CONTRIBUTING.md](CONTRIBUTING.md) and [prismarine-contribute](https://github.com/PrismarineJS/prismarine-contribute)
63
-
64
- ## Usage
65
-
66
- **Videos**
67
-
68
- A tutorial video explaining the basic set up process for a bot can be found [here.](https://www.youtube.com/watch?v=ltWosy4Z0Kw)
69
-
70
- If you want to learn more, more video tutorials are [there,](https://www.youtube.com/playlist?list=PLh_alXmxHmzGy3FKbo95AkPp5D8849PEV) and the corresponding source codes for those bots is [there.](https://github.com/TheDudeFromCI/Mineflayer-Youtube-Tutorials)
71
-
72
- [<img src="https://img.youtube.com/vi/ltWosy4Z0Kw/0.jpg" alt="tutorial 1" width="200">](https://www.youtube.com/watch?v=ltWosy4Z0Kw)
73
- [<img src="https://img.youtube.com/vi/UWGSf08wQSc/0.jpg" alt="tutorial 2" width="200">](https://www.youtube.com/watch?v=UWGSf08wQSc)
74
- [<img src="https://img.youtube.com/vi/ssWE0kXDGJE/0.jpg" alt="tutorial 3" width="200">](https://www.youtube.com/watch?v=ssWE0kXDGJE)
75
- [<img src="https://img.youtube.com/vi/walbRk20KYU/0.jpg" alt="tutorial 4" width="200">](https://www.youtube.com/watch?v=walbRk20KYU)
76
-
77
- **Getting Started**
78
-
79
- Without a version specified, the version of the server will be guessed automatically.
80
- Without auth specified, the mojang auth style will be guessed.
81
-
82
- ### Echo Example
83
- ```js
84
- const mineflayer = require('mineflayer')
85
-
86
- const bot = mineflayer.createBot({
87
- host: 'localhost', // minecraft server ip
88
- username: 'Bot', // username to join as if auth is `offline`, else a unique identifier for this account. Switch if you want to change accounts
89
- auth: 'microsoft' // for offline mode servers, you can set this to 'offline'
90
- // port: 25565, // set if you need a port that isn't 25565
91
- // version: false, // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
92
- // password: '12345678' // set if you want to use password-based auth (may be unreliable). If specified, the `username` must be an email
93
- })
94
-
95
- bot.on('chat', (username, message) => {
96
- if (username === bot.username) return
97
- bot.chat(message)
98
- })
99
-
100
- // Log errors and kick reasons:
101
- bot.on('kicked', console.log)
102
- bot.on('error', console.log)
103
- ```
104
-
105
- If `auth` is set to `microsoft`, you will be prompted to login to microsoft.com with a code in your browser. After signing in on your browser,
106
- the bot will automatically obtain and cache authentication tokens (under your specified username) so you don't have to sign-in again.
107
-
108
- To switch the account, update the supplied `username`. By default, cached tokens will be stored in your user's .minecraft folder, or if `profilesFolder` is specified, they'll instead be stored there.
109
- For more information on bot options see node-minecraft-protocol's [API doc](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/docs/API.md#mccreateclientoptions).
110
-
111
- #### Connecting to a Realm
112
-
113
- To join a Realm that your Minecraft account has been invited to, you can pass a `realms` object with a selector function like below.
114
-
115
- ```js
116
- const client = mineflayer.createBot({
117
- username: 'email@example.com', // minecraft username
118
- realms: {
119
- // This function is called with an array of Realms the account can join. It should return the one it wants to join.
120
- pickRealm: (realms) => realms[0]
121
- },
122
- auth: 'microsoft'
123
- })
124
- ```
125
-
126
- ### See what your bot is doing
127
-
128
- Thanks to the [prismarine-viewer](https://github.com/PrismarineJS/prismarine-viewer) project, it's possible to display in a browser window what your bot is doing.
129
- Just run `npm install prismarine-viewer` and add this to your bot:
130
- ```js
131
- const { mineflayer: mineflayerViewer } = require('prismarine-viewer')
132
- bot.once('spawn', () => {
133
- mineflayerViewer(bot, { port: 3007, firstPerson: true }) // port is the minecraft server port, if first person is false, you get a bird's-eye view
134
- })
135
- ```
136
- And you'll get a *live* view looking like this:
137
-
138
- [<img src="https://prismarinejs.github.io/prismarine-viewer/test_1.16.1.png" alt="viewer" width="500">](https://prismarinejs.github.io/prismarine-viewer/)
139
-
140
- #### More Examples
141
-
142
- | example | description |
143
- |---|---|
144
- |[viewer](https://github.com/PrismarineJS/mineflayer/tree/master/examples/viewer) | Display your bot world view in the browser |
145
- |[pathfinder](https://github.com/PrismarineJS/mineflayer/tree/master/examples/pathfinder) | Make your bot go to any location automatically |
146
- |[chest](https://github.com/PrismarineJS/mineflayer/blob/master/examples/chest.js) | Use chests, furnaces, dispensers, enchantment tables |
147
- |[digger](https://github.com/PrismarineJS/mineflayer/blob/master/examples/digger.js) | Learn how to create a simple bot that is capable of digging blocks |
148
- |[discord](https://github.com/PrismarineJS/mineflayer/blob/master/examples/discord.js) | Connect a discord bot with a mineflayer bot |
149
- |[jumper](https://github.com/PrismarineJS/mineflayer/blob/master/examples/jumper.js) | Learn how to move, jump, ride vehicles, attack nearby entities |
150
- |[ansi](https://github.com/PrismarineJS/mineflayer/blob/master/examples/ansi.js) | Display your bot's chat with all of the chat colors shown in your terminal |
151
- |[guard](https://github.com/PrismarineJS/mineflayer/blob/master/examples/guard.js) | Make a bot guard a defined area from nearby mobs |
152
- |[multiple-from-file](https://github.com/PrismarineJS/mineflayer/blob/master/examples/multiple_from_file.js) | Add a text file with accounts and have them all login |
153
-
154
- And many more in the [examples](https://github.com/PrismarineJS/mineflayer/tree/master/examples) folder.
155
-
156
- ### Modules
157
-
158
- A lot of the active development is happening inside of small npm packages which are used by mineflayer.
159
-
160
- #### The Node Way&trade;
161
-
162
- > "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"](https://gist.github.com/substack/5075355)
163
-
164
- #### Modules
165
-
166
- These are the main modules that make up mineflayer:
167
-
168
- | module | description |
169
- |---|---|
170
- | [minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol) | Parse and serialize minecraft packets, plus authentication and encryption.
171
- | [minecraft-data](https://github.com/PrismarineJS/minecraft-data) | Language independent module providing minecraft data for minecraft clients, servers and libraries.
172
- | [prismarine-physics](https://github.com/PrismarineJS/prismarine-physics) | Provide the physics engine for minecraft entities
173
- | [prismarine-chunk](https://github.com/PrismarineJS/prismarine-chunk) | A class to hold chunk data for Minecraft
174
- | [node-vec3](https://github.com/PrismarineJS/node-vec3) | 3d vector math with robust unit tests
175
- | [prismarine-block](https://github.com/PrismarineJS/prismarine-block) | Represent a minecraft block with its associated data
176
- | [prismarine-chat](https://github.com/PrismarineJS/prismarine-chat) | A parser for a minecraft chat message (extracted from mineflayer)
177
- | [node-yggdrasil](https://github.com/PrismarineJS/node-yggdrasil) | Node.js library to interact with Mojang's authentication system, known as Yggdrasil
178
- | [prismarine-world](https://github.com/PrismarineJS/prismarine-world) | The core implementation of worlds for prismarine
179
- | [prismarine-windows](https://github.com/PrismarineJS/prismarine-windows) | Represent minecraft windows
180
- | [prismarine-item](https://github.com/PrismarineJS/prismarine-item) | Represent a minecraft item with its associated data
181
- | [prismarine-nbt](https://github.com/PrismarineJS/prismarine-nbt) | An NBT parser for node-minecraft-protocol
182
- | [prismarine-recipe](https://github.com/PrismarineJS/prismarine-recipe) | Represent minecraft recipes
183
- | [prismarine-biome](https://github.com/PrismarineJS/prismarine-biome) | Represent a minecraft biome with its associated data
184
- | [prismarine-entity](https://github.com/PrismarineJS/prismarine-entity) | Represent a minecraft entity
185
-
186
-
187
- ### Debug
188
-
189
- You can enable some protocol debugging output using `DEBUG` environment variable:
190
-
191
- ```bash
192
- DEBUG="minecraft-protocol" node [...]
193
- ```
194
-
195
- On windows :
196
- ```
197
- set DEBUG=minecraft-protocol
198
- node your_script.js
199
- ```
200
-
201
- ## Third Party Plugins
202
-
203
- Mineflayer is pluggable; anyone can create a plugin that adds an even
204
- higher level API on top of Mineflayer.
205
-
206
- The most updated and useful are :
207
-
208
- * [minecraft-mcp-server](https://github.com/yuniko-software/minecraft-mcp-server) A MCP server for mineflayer, allowing using mineflayer from an LLM
209
- * [pathfinder](https://github.com/Karang/mineflayer-pathfinder) - advanced A* pathfinding with a lot of configurable features
210
- * [prismarine-viewer](https://github.com/PrismarineJS/prismarine-viewer) - simple web chunk viewer
211
- * [web-inventory](https://github.com/ImHarvol/mineflayer-web-inventory) - web based inventory viewer
212
- * [statemachine](https://github.com/PrismarineJS/mineflayer-statemachine) - A state machine API for more complex bot behaviors
213
- * [Armor Manager](https://github.com/G07cha/MineflayerArmorManager) - automatic armor management
214
- * [Dashboard](https://github.com/wvffle/mineflayer-dashboard) - Frontend dashboard for mineflayer bot
215
- * [PVP](https://github.com/PrismarineJS/mineflayer-pvp) - Easy API for basic PVP and PVE.
216
- * [Auto Eat](https://github.com/link-discord/mineflayer-auto-eat) - Automatic eating of food.
217
- * [Auto Crystal](https://github.com/link-discord/mineflayer-autocrystal) - Automatic placing & breaking of end crystals.
218
- * [Tool](https://github.com/TheDudeFromCI/mineflayer-tool) - A utility for automatic tool/weapon selection with a high level API.
219
- * [Hawkeye](https://github.com/sefirosweb/minecraftHawkEye) - A utility for using auto-aim with bows.
220
- * [GUI](https://github.com/firejoust/mineflayer-GUI) - Interact with nested GUI windows using async/await
221
- * [Projectile](https://github.com/firejoust/mineflayer-projectile) - Get the required launch angle for projectiles
222
- * [Movement](https://github.com/firejoust/mineflayer-movement) - Smooth and realistic player movement, best suited for PvP
223
- * [Collect Block](https://github.com/PrismarineJS/mineflayer-collectblock) - Quick and simple block collection API.
224
-
225
- But also check out :
226
-
227
- * [radar](https://github.com/andrewrk/mineflayer-radar/) - web based radar
228
- interface using canvas and socket.io. [YouTube Demo](https://www.youtube.com/watch?v=FjDmAfcVulQ)
229
- * [auto-auth](https://github.com/G07cha/MineflayerAutoAuth) - chat-based bot authentication
230
- * [Bloodhound](https://github.com/Nixes/mineflayer-bloodhound) - determine who and what is responsible for damage to another entity
231
- * [tps](https://github.com/SiebeDW/mineflayer-tps) - get the current tps (processed tps)
232
- * [panorama](https://github.com/IceTank/mineflayer-panorama) - take Panorama Images of your world
233
- * [player-death-event](https://github.com/tuanzisama/mineflayer-death-event) - emit player death event in Mineflayer.
234
-
235
- ## Projects Using Mineflayer
236
-
237
- * [Voyager](https://github.com/MineDojo/Voyager) An Open-Ended Embodied Agent with Large Language Models
238
- * [mindcraft](https://github.com/kolbytn/mindcraft) Lib for using mineflayer with LLMs
239
- * [rom1504/rbot](https://github.com/rom1504/rbot)
240
- - [YouTube - building a spiral staircase](https://www.youtube.com/watch?v=UM1ZV5200S0)
241
- - [YouTube - replicating a building](https://www.youtube.com/watch?v=0cQxg9uDnzA)
242
- * [Darthfett/Helperbot](https://github.com/Darthfett/Helperbot)
243
- * [vogonistic/voxel](https://github.com/vogonistic/mineflayer-voxel) - visualize what
244
- the bot is up to using voxel.js
245
- * [JonnyD/Skynet](https://github.com/JonnyD/Skynet) - log player activity onto an online API
246
- * [MinecraftChat](https://github.com/rom1504/MinecraftChat) (last open source version, built by AlexKvazos) - Minecraft web based chat client
247
- * [Cheese Bot](https://github.com/Minecheesecraft/Cheese-Bot) - Plugin based bot with a clean GUI. Made with Node-Webkit.
248
- * [Chaoscraft](https://github.com/schematical/chaoscraft) - Minecraft bot using genetic algorithms, see [its youtube videos](https://www.youtube.com/playlist?list=PLLkpLgU9B5xJ7Qy4kOyBJl5J6zsDIMceH)
249
- * [hexatester/minetelegram](https://github.com/hexatester/minetelegram) - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.
250
- * [PrismarineJS/mineflayer-builder](https://github.com/PrismarineJS/mineflayer-builder) - Prints minecraft schematics in survival, keeping orientation
251
- * [SilkePilon/OpenDeliveryBot](https://github.com/SilkePilon/OpenDeliveryBot) - Minecraft bot in python to deliver items from place to place.
252
- * [and hundreds more](https://github.com/PrismarineJS/mineflayer/network/dependents) - All the projects that github detected are using mineflayer
253
-
254
-
255
- ## Testing
256
-
257
- ### Testing everything
258
-
259
- Simply run:
260
-
261
- ```bash
262
- npm test
263
- ```
264
-
265
- ### Testing specific version
266
- Run
267
-
268
- ```bash
269
- npm run mocha_test -- -g <version>
270
- ```
271
-
272
- where `<version>` is a minecraft version like `1.12`, `1.15.2`...
273
-
274
- ### Testing specific test
275
- Run
276
-
277
- ```bash
278
- npm run mocha_test -- -g <test_name>
279
- ```
280
-
281
- where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
282
-
283
- ### Example
284
-
285
- ```bash
286
- npm run mocha_test -- -g "1.18.1.*BlockFinder"
287
- ```
288
- to run the block finder test for 1.18.1
289
-
290
- ## License
291
-
292
- [MIT](/LICENSE)