Skip to content

Commit 4728f7d

Browse files
authored
Merge branch 'master' into switchworld
2 parents cdf69f6 + 08b7317 commit 4728f7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+735
-211
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Setup Java JDK
5353
uses: actions/[email protected]
5454
with:
55-
java-version: 17
55+
java-version: 21
5656
java-package: jre
5757
- name: Install Dependencies
5858
run: npm install

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ test/server_*
1010
.vscode
1111
.DS_Store
1212
launcher_accounts.json
13+
data

.gitpod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
tasks:
2-
- command: npm install
2+
- command: npm install && sdk install java

docs/CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ Mineflayer has two kind of tests :
2222

2323
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.
2424

25+
26+
## Running tests
27+
You can run tests for Different Minecraft versions using the `-g` flag with npm run mocha_test. For example:
28+
29+
```bash
30+
# Run all tests in all supported versions
31+
npm run test
32+
33+
# Run a specific test in Minecraft 1.20.4
34+
npm run mocha_test -- -g "mineflayer_external 1.20.4v.*exampleBee"
35+
36+
# Run all tests in just version 1.20.4
37+
npm run mocha_test -- -g "mineflayer_external 1.20.4v"
38+
```
39+
40+
2541
### Creating an external test
2642

2743
In order to add an external test now you only need to create a file in [test/externalTests](test/externalTests)

docs/FAQ.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This Frequently Asked Question document is meant to help people for the most common things.
44

5+
### I get an error (ie. protocol/data) when bot is trying to connect to minecraft server
6+
7+
Make sure the Minecraft server version is supported (cf. root readme), else you should retry using one of the [mineflayer tested versions](../lib/version.js).
8+
59
### I get an error when trying to login with a microsoft account.
610

711
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.

docs/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
1717

1818
## Features
1919

20-
* Supports Minecraft 1.8 to 1.20.4 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20)
20+
* Supports Minecraft 1.8 to 1.21 (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, and 1.21)
2121
* Entity knowledge and tracking.
2222
* Block knowledge. You can query the world around you. Milliseconds to find any block.
2323
* Physics and movement - handle all bounding boxes
@@ -43,7 +43,7 @@ npm install mineflayer
4343

4444
To update mineflayer (or any Node.js) package and its dependencies, use
4545
```bash
46-
npm update --depth 9999
46+
npm update
4747
```
4848

4949
## Documentation
@@ -234,6 +234,7 @@ The most updated and useful are :
234234
## Projects Using Mineflayer
235235

236236
* [Voyager](https://github.com/MineDojo/Voyager) An Open-Ended Embodied Agent with Large Language Models
237+
* [mindcraft](https://github.com/kolbytn/mindcraft) Lib for using mineflayer with LLMs
237238
* [rom1504/rbot](https://github.com/rom1504/rbot)
238239
- [YouTube - building a spiral staircase](https://www.youtube.com/watch?v=UM1ZV5200S0)
239240
- [YouTube - replicating a building](https://www.youtube.com/watch?v=0cQxg9uDnzA)

docs/api.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
- ["respawn"](#respawn)
170170
- ["game"](#game)
171171
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
172-
- ["title"](#title)
172+
- ["title" (title, type)](#title-title-type)
173173
- ["rain"](#rain)
174174
- ["weatherUpdate"](#weatherupdate)
175175
- ["time"](#time)
@@ -1238,11 +1238,12 @@ Emitted when the server changes any of the game properties.
12381238

12391239
Emitted when the server sends a resource pack.
12401240

1241-
#### "title"
1241+
#### "title" (title, type)
12421242

12431243
Emitted when the server sends a title
12441244

1245-
* `text` - title's text
1245+
* `title` - title's text
1246+
* `type` - title's type "subtitle" or "title"
12461247

12471248
#### "rain"
12481249

@@ -1777,7 +1778,7 @@ Checks if the given plugin is loaded (or scheduled to be loaded) on this bot.
17771778

17781779
This function returns a `Promise`, with `void` as its argument upon completion.
17791780

1780-
Sleep in a bed. `bedBlock` should be a `Block` instance which is a bed.
1781+
Sleep in a bed. `bedBlock` should be a `Block` instance which is a bed.
17811782

17821783
#### bot.isABed(bedBlock)
17831784

@@ -1787,7 +1788,7 @@ Return true if `bedBlock` is a bed
17871788

17881789
This function returns a `Promise`, with `void` as its argument upon completion.
17891790

1790-
Get out of bed.
1791+
Get out of bed.
17911792

17921793
#### bot.setControlState(control, state)
17931794

@@ -2126,7 +2127,7 @@ These are lower level methods for the inventory, they can be useful sometimes bu
21262127
#### bot.clickWindow(slot, mouseButton, mode)
21272128

21282129
This function returns a `Promise`, with `void` as its argument upon completion.
2129-
2130+
21302131
The only valid mode option at the moment is 0. Shift clicking or mouse dragging is not implemented.
21312132

21322133
Click on the current window. See details at https://wiki.vg/Protocol#Click_Container

docs/br/api_br.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
- ["respawn"](#respawn)
142142
- ["game"](#game)
143143
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
144-
- ["title"](#title)
144+
- ["title" (title, type)](#title-title-type)
145145
- ["rain"](#rain)
146146
- ["weatherUpdate"](#weatherupdate)
147147
- ["time"](#time)
@@ -1060,11 +1060,12 @@ Este evento é emitido quando o arquivo index é carregado. Você pode carregar
10601060

10611061
É emitido quando o servidor envia um pacote de recursos.
10621062

1063-
#### "title"
1063+
#### "title" (title, type)
10641064

10651065
É emitido quando o servidor exibe um título.
10661066

1067-
* `text` - texto do título
1067+
* `title` - texto do título
1068+
* `type` - tipo do título "subtitle" ou "title"
10681069

10691070
#### "rain"
10701071

@@ -2035,4 +2036,4 @@ Observação: enquanto você voa, `bot.entity.velocity` não é preciso.
20352036

20362037
#### bot.creative.stopFlying()
20372038

2038-
Restaura `bot.physics.gravity` ao seu valor original.
2039+
Restaura `bot.physics.gravity` ao seu valor original.

docs/es/api_es.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
- ["respawn"](#respawn)
142142
- ["game"](#game)
143143
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
144-
- ["title"](#title)
144+
- ["title" (title, type)](#title-title-type)
145145
- ["rain"](#rain)
146146
- ["weatherUpdate"](#weatherupdate)
147147
- ["time"](#time)
@@ -1071,11 +1071,12 @@ Se emite cuando el servidor cambia cualquiera de sus propiedades
10711071

10721072
Se emite cuando el servidor manda un paquete de recursos
10731073

1074-
#### "title"
1074+
#### "title" (title, type)
10751075

10761076
Se emite cuando el servidor manda/muestra un título
10771077

1078-
* `text` - texto del título
1078+
* `title` - texto del título
1079+
* `type` - tipo del título "subtitle" o "title"
10791080

10801081
#### "rain"
10811082

docs/history.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
## 4.25.0
2+
* [1.21.4 (#3546)](https://github.com/PrismarineJS/mineflayer/commit/8bbf5669f5ff3ea8a708633e51b47c312dc7a26b) (thanks @extremeheat)
3+
4+
## 4.24.0
5+
* [Support 1.21.3. (#3489)](https://github.com/PrismarineJS/mineflayer/commit/58ae9e5b5abf75139f4ba93fe4f34ef7ed3936e8) (thanks @rom1504)
6+
* [Fix out of bounds access leading to crash at spawn (#3535)](https://github.com/PrismarineJS/mineflayer/commit/3187368397e880ba8b32bb03affa18203cbcbb42) (thanks @wAIfu-DEV)
7+
* [fix: use dimension data on 1.16.2 (#3397)](https://github.com/PrismarineJS/mineflayer/commit/f6187f66c16dd122165287be7864c78b2fe7c32c) (thanks @zardoy)
8+
* [update contribution docs to show test running commands (#3511)](https://github.com/PrismarineJS/mineflayer/commit/71a3a262681a173db86b8911aec82402a6993d21) (thanks @Madlykeanu)
9+
* [Update inventory.js (#3507)](https://github.com/PrismarineJS/mineflayer/commit/a0e92cad5887181bf7e235f69378c8ede14a350c) (thanks @Pix3lPirat3)
10+
* [Update FAQ.md - add mineflayer tested versions : lib/version.js (#3517)](https://github.com/PrismarineJS/mineflayer/commit/f2dd3a37505b374bf63119633659e35ec2ce3542) (thanks @boly38)
11+
* [Bump protodef from 1.17.0 to 1.18.0 (#3523)](https://github.com/PrismarineJS/mineflayer/commit/06faa36c2da3da399bd5370869700aea6c65c9b0) (thanks @dependabot[bot])
12+
* [Bump mocha from 10.8.2 to 11.0.1 (#3516)](https://github.com/PrismarineJS/mineflayer/commit/166971d317db3ec68cf3eebeda37f509152628fd) (thanks @dependabot[bot])
13+
* [Fix chatterbox example (#3506)](https://github.com/PrismarineJS/mineflayer/commit/386200759556aa261fa212f26c43992a66cfa8ac) (thanks @ShiftSad)
14+
* [Proper title event (#3498)](https://github.com/PrismarineJS/mineflayer/commit/3829a25150eec782bc045a222476865af7b0ac72) (thanks @SMEDjs)
15+
* [Set `sequence` field correctly in activateItem (#3445)](https://github.com/PrismarineJS/mineflayer/commit/fdba03737ecdeaaf419e3175b9be33291db4e085) (thanks @GenerelSchwerz)
16+
* [increase timeout in external test common](https://github.com/PrismarineJS/mineflayer/commit/3d6e2344751c38428701dc52e9f29dda73f7f782) (thanks @rom1504)
17+
18+
## 4.23.0
19+
* [1.21 (#3480)](https://github.com/PrismarineJS/mineflayer/commit/4aa10fb45431940504c7809f078f1f410e7fa7a3) (thanks @Madlykeanu)
20+
* [Adding mindcraft to mineflayer readme](https://github.com/PrismarineJS/mineflayer/commit/dd00db42ba20682418d8fbd5629e1033dfb0ff20) (thanks @rom1504)
21+
22+
## 4.22.0
23+
* [Remove debug logging (#3478)](https://github.com/PrismarineJS/mineflayer/commit/eb29d350ede0590fce17e04bf21071807a87e3a1) (thanks @extremeheat)
24+
25+
## 4.21.0
26+
* [1.20.6 (#3412)](https://github.com/PrismarineJS/mineflayer/commit/44fad41c18be5024564e24e1cdee624d35d4d387) (thanks @extremeheat)
27+
* [Update README.md (#3420)](https://github.com/PrismarineJS/mineflayer/commit/1c2a5c0fa78f74a63fabd7edde85c4a74db32dee) (thanks @SilkePilon)
28+
* [types: add pitchSpeed as an option in typings (#3446)](https://github.com/PrismarineJS/mineflayer/commit/05b48ad0dad4cf64a1c11660bac256d7b4015841) (thanks @GenerelSchwerz)
29+
* [Fixed a bug with not closing the window when changing the subserver (#3424)](https://github.com/PrismarineJS/mineflayer/commit/d00c386cfe51cefc361c0ff4d30b100aee9f114a) (thanks @DenisKvak1)
30+
* [Bump @types/node from 20.14.14 to 22.1.0 (#3431)](https://github.com/PrismarineJS/mineflayer/commit/1d461616b514969fdece38e49bfbec747ab8d76a) (thanks @dependabot[bot])
31+
* [Fix updateSlot event type (#3425)](https://github.com/PrismarineJS/mineflayer/commit/5d39db26a6ab17baac38b68af8ccd3eeb4af3def) (thanks @DenisKvak1)
32+
* [Player hitbox fixes (#3382)](https://github.com/PrismarineJS/mineflayer/commit/78b4eccb4572a821b11c3124b7a593f3b91f1180) (thanks @AreaDenial)
33+
* [Typo fixes (#3418)](https://github.com/PrismarineJS/mineflayer/commit/ef042a242ca9f5fc5820fe4dc2e1d997ef1db202) (thanks @kgurchiek)
34+
* [Added support for 1.18+ edit book packet #3204 (#3373)](https://github.com/PrismarineJS/mineflayer/commit/eb9982aa04973b0086aac68a2847005d77f01a3d) (thanks @unlimitedcoder2)
35+
* [Fix typos (#3381)](https://github.com/PrismarineJS/mineflayer/commit/d581ea7cee4d5b7df9606f671656bb0be0fdbf91) (thanks @data-miner00)
36+
* [Fix typescript types syntax for setCommandBlock (#3366)](https://github.com/PrismarineJS/mineflayer/commit/315cdfc4b1fc2760e4a8a36feb718626a66d5056) (thanks @undefined)
37+
* [Remove invalid sign check (#3328)](https://github.com/PrismarineJS/mineflayer/commit/ec76468c8ac4c6232bad3c2b66d4160f95f58396) (thanks @zardoy)
38+
* [refactor: simplifying the code of blockAtCursor (#3337)](https://github.com/PrismarineJS/mineflayer/commit/dc70f932ac9aaab6e6cdb15057b409b15c3232dd) (thanks @SnowRunescape)
39+
* [Updated setCommandBlock's 3rd argument (#3356)](https://github.com/PrismarineJS/mineflayer/commit/04ad6db404f0da779004b3ddd0e049bf2c6be0a3) (thanks @FlooferLand)
40+
* [Added the serverBrand property to index.d.ts (#3355)](https://github.com/PrismarineJS/mineflayer/commit/0bb2707d2f6d0d64a467d4e0d6ddc52adf526127) (thanks @Khaogamermain01)
41+
142
## 4.20.1
243
* [Add bossBarCreated event in index.d.ts (#3340)](https://github.com/PrismarineJS/mineflayer/commit/8299288526cd7ff24bcd87511814221f8ad62507) (thanks @gguio)
344
* [Update scoreboard.js (#3318)](https://github.com/PrismarineJS/mineflayer/commit/195b3cbd70a110080af9b77a4659991c5d9e484a) (thanks @vicdum)

docs/ru/api_ru.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
- ["respawn"](#respawn)
170170
- ["game"](#game)
171171
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
172-
- ["title"](#title)
172+
- ["title" (title, type)](#title-title-type)
173173
- ["rain"](#rain)
174174
- ["weatherUpdate"](#weatherupdate)
175175
- ["time"](#time)
@@ -1264,11 +1264,12 @@ UUID существа, который определяется боссом.
12641264

12651265
Срабатывает, когда сервер отправляет ресурспак.
12661266

1267-
#### "title"
1267+
#### "title" (title, type)
12681268

12691269
Срабатывает, когда сервер отправляет текст по центру экрана.
12701270

1271-
* `text` - Текст на экране.
1271+
* `title` - Текст на экране.
1272+
* `type` - Тип текста "subtitle" или "title"
12721273

12731274
#### "rain"
12741275

@@ -1634,7 +1635,7 @@ UUID существа, который определяется боссом.
16341635

16351636
#### bot.recipesFor(itemType, metadata, minResultCount, craftingTable)
16361637

1637-
Возвращает список рецептов(`Recipe`), которые вы можете использовать для крафта
1638+
Возвращает список рецептов(`Recipe`), которые вы можете использовать для крафта
16381639
предмета(`itemType`) с мета-данными(`metadata`).
16391640

16401641
* `itemType` - Числовой ID предмета, который вы хотите создать.
@@ -2116,7 +2117,7 @@ bot.once('login', () => {
21162117
#### bot.clickWindow(slot, mouseButton, mode)
21172118

21182119
Эта функция возвращает `Promise` с `void` в качестве аргумента при завершении.
2119-
2120+
21202121
Единственное действительное значение для `mode` - 0. Нажатие с шифтом или перемещение через мышь не реализовано.
21212122

21222123
Нажимает на текущее окно. Подробнее - https://wiki.vg/Protocol#Click_Container

docs/zh/api.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
- ["respawn"](#respawn)
154154
- ["game"](#game)
155155
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
156-
- ["title"](#title)
156+
- ["title" (title, type)](#title-title-type)
157157
- ["rain"](#rain)
158158
- ["weatherUpdate"](#weatherupdate)
159159
- ["time"](#time)
@@ -1127,11 +1127,12 @@ Emitted for every server message, including chats.
11271127

11281128
当服务器发送资源包时触发
11291129

1130-
#### "title"
1130+
#### "title" (title, type)
11311131

11321132
当服务器发送标题时触发
11331133

1134-
* `text` - 标题文本
1134+
* `title` - 标题文本
1135+
* `type` - 标题类型 "subtitle" 或 "title"
11351136

11361137
#### "rain"
11371138

@@ -1150,11 +1151,11 @@ If you join a server where it is already raining, this event will fire.
11501151

11511152
当bot从服务器被踢出时触发
11521153

1153-
`reason`是一条解释你被踢的原因的聊天信息.
1154+
`reason`是一条解释你被踢的原因的聊天信息.
11541155

11551156
`loggedIn`
11561157
如果客户端在成功登录后被踢出则为`true`
1157-
如果kick发生在登录阶段则为 `false`
1158+
如果kick发生在登录阶段则为 `false`
11581159

11591160
#### "end" (reason)
11601161

examples/echo.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
const mineflayer = require('mineflayer')
1010

1111
if (process.argv.length < 4 || process.argv.length > 6) {
12-
console.log('Usage : node echo.js <host> <port> [<name>] [<password>]')
12+
console.log('Usage : node echo.js <host> <port> [<name>] [online?]')
1313
process.exit(1)
1414
}
1515

1616
const bot = mineflayer.createBot({
1717
host: process.argv[2],
1818
port: parseInt(process.argv[3]),
1919
username: process.argv[4] ? process.argv[4] : 'echo',
20-
password: process.argv[5]
20+
auth: process.argv[5] ? 'microsoft' : 'offline'
2121
})
2222

2323
bot.on('chat', (username, message) => {
2424
if (username === bot.username) return
2525
bot.chat(message)
2626
})
27+
28+
bot.on('kicked', (reason) => {
29+
console.log('I was kicked from the server: ' + reason)
30+
})

examples/python/chatterbox.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
bot = mineflayer.createBot({
3131
"host": host,
3232
"port": port,
33-
"username": username,
34-
"port": port
33+
"username": username
3534
})
3635

3736
Item = require("prismarine-item")(bot.registry)
@@ -300,4 +299,4 @@ def entityEffect(this, entity, effect):
300299

301300
@On(bot, "entityEffectEnd")
302301
def entityEffectEnd(this, entity, effect):
303-
print("entityEffectEnd", entity, effect)
302+
print("entityEffectEnd", entity, effect)

examples/titles.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* An example of how to handle title events from the server.
3+
*/
4+
const mineflayer = require('mineflayer')
5+
6+
if (process.argv.length < 4 || process.argv.length > 6) {
7+
console.log('Usage : node titles.js <host> <port> [<name>] [<password>]')
8+
process.exit(1)
9+
}
10+
11+
const bot = mineflayer.createBot({
12+
host: process.argv[2],
13+
port: parseInt(process.argv[3]),
14+
username: process.argv[4] ? process.argv[4] : 'titles',
15+
password: process.argv[5]
16+
})
17+
18+
// This event is triggered when the server sends a title to the client.
19+
bot.on('title', (text, type) => {
20+
// type is either "title" or "subtitle"
21+
console.log(`Received ${type}: ${text}`)
22+
})

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface BotEvents {
7171
spawn: () => Promise<void> | void
7272
respawn: () => Promise<void> | void
7373
game: () => Promise<void> | void
74-
title: (text: string) => Promise<void> | void
74+
title: (text: string, type: "subtitle" | "title") => Promise<void> | void
7575
rain: () => Promise<void> | void
7676
time: () => Promise<void> | void
7777
kicked: (reason: string, loggedIn: boolean) => Promise<void> | void
@@ -542,6 +542,7 @@ export interface PhysicsOptions {
542542
playerHeight: number
543543
jumpSpeed: number
544544
yawSpeed: number
545+
pitchSpeed: number
545546
sprintSpeed: number
546547
maxGroundSpeedSoulSand: number
547548
maxGroundSpeedWater: number

lib/loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function createBot (options = {}) {
9595
}).map(key => options.plugins[key])
9696
bot.loadPlugins([...internalPlugins, ...externalPlugins])
9797

98+
options.validateChannelProtocol = false
9899
bot._client = bot._client ?? mc.createClient(options)
99100
bot._client.on('connect', () => {
100101
bot.emit('connect')

0 commit comments

Comments
 (0)