Skip to content

Commit

Permalink
Merge branch 'master' into optimistic-place
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Jan 22, 2025
2 parents 1995a47 + e974e70 commit ecce1d2
Show file tree
Hide file tree
Showing 52 changed files with 819 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: 17
java-version: 21
java-package: jre
- name: Install Dependencies
run: npm install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ test/server_*
.vscode
.DS_Store
launcher_accounts.json
data
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tasks:
- command: npm install
- command: npm install && sdk install java
16 changes: 16 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ Mineflayer has two kind of tests :

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.


## Running tests
You can run tests for Different Minecraft versions using the `-g` flag with npm run mocha_test. For example:

```bash
# Run all tests in all supported versions
npm run test

# Run a specific test in Minecraft 1.20.4
npm run mocha_test -- -g "mineflayer_external 1.20.4v.*exampleBee"

# Run all tests in just version 1.20.4
npm run mocha_test -- -g "mineflayer_external 1.20.4v"
```


### Creating an external test

In order to add an external test now you only need to create a file in [test/externalTests](test/externalTests)
Expand Down
4 changes: 4 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

### I get an error (ie. protocol/data) when bot is trying to connect to minecraft server

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

### I get an error when trying to login with a microsoft account.

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.
Expand Down
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)

## Features

* 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)
* 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)
* Entity knowledge and tracking.
* Block knowledge. You can query the world around you. Milliseconds to find any block.
* Physics and movement - handle all bounding boxes
Expand All @@ -43,7 +43,7 @@ npm install mineflayer

To update mineflayer (or any Node.js) package and its dependencies, use
```bash
npm update --depth 9999
npm update
```

## Documentation
Expand Down Expand Up @@ -234,6 +234,7 @@ The most updated and useful are :
## Projects Using Mineflayer

* [Voyager](https://github.com/MineDojo/Voyager) An Open-Ended Embodied Agent with Large Language Models
* [mindcraft](https://github.com/kolbytn/mindcraft) Lib for using mineflayer with LLMs
* [rom1504/rbot](https://github.com/rom1504/rbot)
- [YouTube - building a spiral staircase](https://www.youtube.com/watch?v=UM1ZV5200S0)
- [YouTube - replicating a building](https://www.youtube.com/watch?v=0cQxg9uDnzA)
Expand Down
43 changes: 22 additions & 21 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
- ["respawn"](#respawn)
- ["game"](#game)
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
- ["title"](#title)
- ["title" (title, type)](#title-title-type)
- ["rain"](#rain)
- ["weatherUpdate"](#weatherupdate)
- ["time"](#time)
Expand Down Expand Up @@ -808,7 +808,7 @@ Create and return an instance of the class bot.
* checkTimeoutInterval : default to `30*1000` (30s), check if keepalive received at that period, disconnect otherwise.
* loadInternalPlugins : defaults to true
* storageBuilder : an optional function, takes as argument version and worldName and return an instance of something with the same API as prismarine-provider-anvil. Will be used to save the world.
* client : an instance of node-minecraft-protocol, if not specified, mineflayer makes it's own client. This can be used to enable using mineflayer through a proxy of many clients or a vanilla client and a mineflayer client.
* client : an instance of node-minecraft-protocol, if not specified, mineflayer makes its own client. This can be used to enable using mineflayer through a proxy of many clients or a vanilla client and a mineflayer client.
* brand : the brand name for the client to use. Defaults to vanilla. Can be used to simulate custom clients for servers that require it.
* respawn : when set to false disables bot from automatically respawning, defaults to true.
* plugins : object : defaults to {}
Expand Down Expand Up @@ -974,7 +974,7 @@ Default true, whether or not you receive color codes in chats from the server.

#### bot.settings.viewDistance

Can be a string listed below or a postive number.
Can be a string listed below or a positive number.
Choices:
* `far` (default)
* `normal`
Expand Down Expand Up @@ -1035,7 +1035,7 @@ saturation of 5.0. Eating food increases the saturation as well as the food bar.

#### bot.oxygenLevel

Number in the range [0, 20] respresenting the number of water-icons known as oxygen level.
Number in the range [0, 20] representing the number of water-icons known as oxygen level.

#### bot.physics

Expand Down Expand Up @@ -1237,11 +1237,12 @@ Emitted when the server changes any of the game properties.

Emitted when the server sends a resource pack.

#### "title"
#### "title" (title, type)

Emitted when the server sends a title

* `text` - title's text
* `title` - title's text
* `type` - title's type "subtitle" or "title"

#### "rain"

Expand Down Expand Up @@ -1554,7 +1555,7 @@ Fires when a particle is created

#### bot.blockAt(point, extraInfos=true)

Returns the block at `point` or `null` if that point is not loaded. If `extraInfos` set to true, also returns informations about signs, paintings and block entities (slower).
Returns the block at `point` or `null` if that point is not loaded. If `extraInfos` set to true, also returns information about signs, paintings and block entities (slower).
See `Block`.

#### bot.waitForChunksToLoad()
Expand Down Expand Up @@ -1596,8 +1597,8 @@ Finds the closest blocks from the given point.
- `point` - The start position of the search (center). Default is the bot position.
- `matching` - A function that returns true if the given block is a match. Also supports this value being a block id or array of block ids.
- `useExtraInfo` - To preserve backward compatibility can result in two behavior depending on the type
- **boolean** - Provide your `matching` function more data - noticeably slower aproach
- **function** - Creates two stage maching, if block passes `matching` function it is passed further to `useExtraInfo` with additional info
- **boolean** - Provide your `matching` function more data - noticeably slower approach
- **function** - Creates two stage matching, if block passes `matching` function it is passed further to `useExtraInfo` with additional info
- `maxDistance` - The furthest distance for the search, defaults to 16.
- `count` - Number of blocks to find before returning the search. Default to 1. Can return less if not enough blocks are found exploring the whole area.

Expand Down Expand Up @@ -1627,15 +1628,15 @@ with `metadata`.

#### bot.recipesAll(itemType, metadata, craftingTable)

The same as bot.recipesFor except that it does not check wether the bot has enough materials for the recipe.
The same as bot.recipesFor except that it does not check whether the bot has enough materials for the recipe.

#### bot.nearestEntity(match = (entity) => { return true })

Return the nearest entity to the bot, matching the function (default to all entities). Return null if no entity is found.

Example:
```js
const cow = bot.nearestEntity(entity => entity.name.toLowerCase() === 'cow') // we use .toLowercase() because in 1.8 cow was capitalized, for newer versions that can be ommitted
const cow = bot.nearestEntity(entity => entity.name.toLowerCase() === 'cow') // we use .toLowercase() because in 1.8 cow was capitalized, for newer versions that can be omitted
```

### Methods
Expand All @@ -1657,7 +1658,7 @@ Requests chat completion from the server.
* `str` - String to complete.
* `assumeCommand` - Field sent to server, defaults to false.
* `sendBlockInSight` - Field sent to server, defaults to true. Set this option to false if you want more performance.
* `timeout` - Timeout in milliseconds, after which the function will return an ampty array, defaults to 5000.
* `timeout` - Timeout in milliseconds, after which the function will return an empty array, defaults to 5000.

#### bot.chat(message)

Expand All @@ -1683,22 +1684,22 @@ Adds a regex pattern to the bot's chat matching. Useful for bukkit servers where
make an event that is called every time the pattern is matched to a message,
the event will be called `"chat:name"`, with name being the name passed
* `name` - the name used to listen for the event
* `pattern` - regular expression to match to messages recieved
* `pattern` - regular expression to match to messages received
* `chatPatternOptions` - object
* `repeat` - defaults to true, whether to listen for this event after the first match
* `parse` - instead of returning the actual message that was matched, return the capture groups from the regex
* `deprecated` - (**unstable**) used by bot.chatAddPattern to keep compatability, likely to be removed
* `deprecated` - (**unstable**) used by bot.chatAddPattern to keep compatibility, likely to be removed

returns a number which can be used with bot.removeChatPattern() to only delete this pattern

- :eyes: cf. [examples/chat_parsing](https://github.com/PrismarineJS/mineflayer/blob/master/examples/chat_parsing.js#L17-L36)

#### bot.addChatPatternSet(name, patterns, chatPatternOptions)

make an event that is called every time all patterns havee been matched to messages,
make an event that is called every time all patterns have been matched to messages,
the event will be called `"chat:name"`, with name being the name passed
* `name` - the name used to listen for the event
* `patterns` - array of regular expression to match to messages recieved
* `patterns` - array of regular expression to match to messages received
* `chatPatternOptions` - object
* `repeat` - defaults to true, whether to listen for this event after the first match
* `parse` - instead of returning the actual message that was matched, return the capture groups from the regex
Expand Down Expand Up @@ -1771,7 +1772,7 @@ Checks if the given plugin is loaded (or scheduled to be loaded) on this bot.

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

Sleep in a bed. `bedBlock` should be a `Block` instance which is a bed.
Sleep in a bed. `bedBlock` should be a `Block` instance which is a bed.

#### bot.isABed(bedBlock)

Expand All @@ -1781,7 +1782,7 @@ Return true if `bedBlock` is a bed

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

Get out of bed.
Get out of bed.

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

Expand Down Expand Up @@ -1892,7 +1893,7 @@ dig any other blocks until the block has been broken, or you call
`bot.stopDigging()`.

* `block` - the block to start digging into
* `forceLook` - (optional) if true, look at the block and start mining instantly. If false, the bot will slowly turn to the block to mine. Additionally, this can be assigned to 'ignore' to prevent the bot from moving it's head at all. Also, this can be assigned to 'raycast' to raycast from the bots head to place where the bot is looking.
* `forceLook` - (optional) if true, look at the block and start mining instantly. If false, the bot will slowly turn to the block to mine. Additionally, this can be assigned to 'ignore' to prevent the bot from moving its head at all. Also, this can be assigned to 'raycast' to raycast from the bots head to place where the bot is looking.
* `digFace` - (optional) Default is 'auto' looks at the center of the block and mines the top face. Can also be a vec3 vector
of the face the bot should be looking at when digging the block. For example: ```vec3(0, 1, 0)``` when mining the top. Can also be 'raycast' raycast checks if there is a face visible by the bot and mines that face. Useful for servers with anti cheat.

Expand Down Expand Up @@ -2120,7 +2121,7 @@ These are lower level methods for the inventory, they can be useful sometimes bu
#### bot.clickWindow(slot, mouseButton, mode)

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

The only valid mode option at the moment is 0. Shift clicking or mouse dragging is not implemented.

Click on the current window. See details at https://wiki.vg/Protocol#Click_Container
Expand Down Expand Up @@ -2249,4 +2250,4 @@ Note that while flying, `bot.entity.velocity` will not be accurate.

#### bot.creative.stopFlying()

Restores `bot.physics.gravity` to it's original value.
Restores `bot.physics.gravity` to its original value.
9 changes: 5 additions & 4 deletions docs/br/api_br.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
- ["respawn"](#respawn)
- ["game"](#game)
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
- ["title"](#title)
- ["title" (title, type)](#title-title-type)
- ["rain"](#rain)
- ["weatherUpdate"](#weatherupdate)
- ["time"](#time)
Expand Down Expand Up @@ -1060,11 +1060,12 @@ Este evento é emitido quando o arquivo index é carregado. Você pode carregar

É emitido quando o servidor envia um pacote de recursos.

#### "title"
#### "title" (title, type)

É emitido quando o servidor exibe um título.

* `text` - texto do título
* `title` - texto do título
* `type` - tipo do título "subtitle" ou "title"

#### "rain"

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

#### bot.creative.stopFlying()

Restaura `bot.physics.gravity` ao seu valor original.
Restaura `bot.physics.gravity` ao seu valor original.
7 changes: 4 additions & 3 deletions docs/es/api_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
- ["respawn"](#respawn)
- ["game"](#game)
- ["resourcePack" (url, hash)](#resourcepack-url-hash)
- ["title"](#title)
- ["title" (title, type)](#title-title-type)
- ["rain"](#rain)
- ["weatherUpdate"](#weatherupdate)
- ["time"](#time)
Expand Down Expand Up @@ -1071,11 +1071,12 @@ Se emite cuando el servidor cambia cualquiera de sus propiedades

Se emite cuando el servidor manda un paquete de recursos

#### "title"
#### "title" (title, type)

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

* `text` - texto del título
* `title` - texto del título
* `type` - tipo del título "subtitle" o "title"

#### "rain"

Expand Down
41 changes: 41 additions & 0 deletions docs/history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
## 4.25.0
* [1.21.4 (#3546)](https://github.com/PrismarineJS/mineflayer/commit/8bbf5669f5ff3ea8a708633e51b47c312dc7a26b) (thanks @extremeheat)

## 4.24.0
* [Support 1.21.3. (#3489)](https://github.com/PrismarineJS/mineflayer/commit/58ae9e5b5abf75139f4ba93fe4f34ef7ed3936e8) (thanks @rom1504)
* [Fix out of bounds access leading to crash at spawn (#3535)](https://github.com/PrismarineJS/mineflayer/commit/3187368397e880ba8b32bb03affa18203cbcbb42) (thanks @wAIfu-DEV)
* [fix: use dimension data on 1.16.2 (#3397)](https://github.com/PrismarineJS/mineflayer/commit/f6187f66c16dd122165287be7864c78b2fe7c32c) (thanks @zardoy)
* [update contribution docs to show test running commands (#3511)](https://github.com/PrismarineJS/mineflayer/commit/71a3a262681a173db86b8911aec82402a6993d21) (thanks @Madlykeanu)
* [Update inventory.js (#3507)](https://github.com/PrismarineJS/mineflayer/commit/a0e92cad5887181bf7e235f69378c8ede14a350c) (thanks @Pix3lPirat3)
* [Update FAQ.md - add mineflayer tested versions : lib/version.js (#3517)](https://github.com/PrismarineJS/mineflayer/commit/f2dd3a37505b374bf63119633659e35ec2ce3542) (thanks @boly38)
* [Bump protodef from 1.17.0 to 1.18.0 (#3523)](https://github.com/PrismarineJS/mineflayer/commit/06faa36c2da3da399bd5370869700aea6c65c9b0) (thanks @dependabot[bot])
* [Bump mocha from 10.8.2 to 11.0.1 (#3516)](https://github.com/PrismarineJS/mineflayer/commit/166971d317db3ec68cf3eebeda37f509152628fd) (thanks @dependabot[bot])
* [Fix chatterbox example (#3506)](https://github.com/PrismarineJS/mineflayer/commit/386200759556aa261fa212f26c43992a66cfa8ac) (thanks @ShiftSad)
* [Proper title event (#3498)](https://github.com/PrismarineJS/mineflayer/commit/3829a25150eec782bc045a222476865af7b0ac72) (thanks @SMEDjs)
* [Set `sequence` field correctly in activateItem (#3445)](https://github.com/PrismarineJS/mineflayer/commit/fdba03737ecdeaaf419e3175b9be33291db4e085) (thanks @GenerelSchwerz)
* [increase timeout in external test common](https://github.com/PrismarineJS/mineflayer/commit/3d6e2344751c38428701dc52e9f29dda73f7f782) (thanks @rom1504)

## 4.23.0
* [1.21 (#3480)](https://github.com/PrismarineJS/mineflayer/commit/4aa10fb45431940504c7809f078f1f410e7fa7a3) (thanks @Madlykeanu)
* [Adding mindcraft to mineflayer readme](https://github.com/PrismarineJS/mineflayer/commit/dd00db42ba20682418d8fbd5629e1033dfb0ff20) (thanks @rom1504)

## 4.22.0
* [Remove debug logging (#3478)](https://github.com/PrismarineJS/mineflayer/commit/eb29d350ede0590fce17e04bf21071807a87e3a1) (thanks @extremeheat)

## 4.21.0
* [1.20.6 (#3412)](https://github.com/PrismarineJS/mineflayer/commit/44fad41c18be5024564e24e1cdee624d35d4d387) (thanks @extremeheat)
* [Update README.md (#3420)](https://github.com/PrismarineJS/mineflayer/commit/1c2a5c0fa78f74a63fabd7edde85c4a74db32dee) (thanks @SilkePilon)
* [types: add pitchSpeed as an option in typings (#3446)](https://github.com/PrismarineJS/mineflayer/commit/05b48ad0dad4cf64a1c11660bac256d7b4015841) (thanks @GenerelSchwerz)
* [Fixed a bug with not closing the window when changing the subserver (#3424)](https://github.com/PrismarineJS/mineflayer/commit/d00c386cfe51cefc361c0ff4d30b100aee9f114a) (thanks @DenisKvak1)
* [Bump @types/node from 20.14.14 to 22.1.0 (#3431)](https://github.com/PrismarineJS/mineflayer/commit/1d461616b514969fdece38e49bfbec747ab8d76a) (thanks @dependabot[bot])
* [Fix updateSlot event type (#3425)](https://github.com/PrismarineJS/mineflayer/commit/5d39db26a6ab17baac38b68af8ccd3eeb4af3def) (thanks @DenisKvak1)
* [Player hitbox fixes (#3382)](https://github.com/PrismarineJS/mineflayer/commit/78b4eccb4572a821b11c3124b7a593f3b91f1180) (thanks @AreaDenial)
* [Typo fixes (#3418)](https://github.com/PrismarineJS/mineflayer/commit/ef042a242ca9f5fc5820fe4dc2e1d997ef1db202) (thanks @kgurchiek)
* [Added support for 1.18+ edit book packet #3204 (#3373)](https://github.com/PrismarineJS/mineflayer/commit/eb9982aa04973b0086aac68a2847005d77f01a3d) (thanks @unlimitedcoder2)
* [Fix typos (#3381)](https://github.com/PrismarineJS/mineflayer/commit/d581ea7cee4d5b7df9606f671656bb0be0fdbf91) (thanks @data-miner00)
* [Fix typescript types syntax for setCommandBlock (#3366)](https://github.com/PrismarineJS/mineflayer/commit/315cdfc4b1fc2760e4a8a36feb718626a66d5056) (thanks @undefined)
* [Remove invalid sign check (#3328)](https://github.com/PrismarineJS/mineflayer/commit/ec76468c8ac4c6232bad3c2b66d4160f95f58396) (thanks @zardoy)
* [refactor: simplifying the code of blockAtCursor (#3337)](https://github.com/PrismarineJS/mineflayer/commit/dc70f932ac9aaab6e6cdb15057b409b15c3232dd) (thanks @SnowRunescape)
* [Updated setCommandBlock's 3rd argument (#3356)](https://github.com/PrismarineJS/mineflayer/commit/04ad6db404f0da779004b3ddd0e049bf2c6be0a3) (thanks @FlooferLand)
* [Added the serverBrand property to index.d.ts (#3355)](https://github.com/PrismarineJS/mineflayer/commit/0bb2707d2f6d0d64a467d4e0d6ddc52adf526127) (thanks @Khaogamermain01)

## 4.20.1
* [Add bossBarCreated event in index.d.ts (#3340)](https://github.com/PrismarineJS/mineflayer/commit/8299288526cd7ff24bcd87511814221f8ad62507) (thanks @gguio)
* [Update scoreboard.js (#3318)](https://github.com/PrismarineJS/mineflayer/commit/195b3cbd70a110080af9b77a4659991c5d9e484a) (thanks @vicdum)
Expand Down
Loading

0 comments on commit ecce1d2

Please sign in to comment.