Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jun 6, 2024
2 parents 95cec39 + 315cdfc commit ab9d39a
Show file tree
Hide file tree
Showing 88 changed files with 6,258 additions and 1,371 deletions.
50 changes: 26 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,49 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1.4.4
with:
node-version: 14.x
node-version: 18.x
- run: npm i && npm run lint

PrepareSupportedVersions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v1.4.4
with:
node-version: 18.x
- id: set-matrix
run: |
node -e "
const testedVersions = require('./lib/version').testedVersions;
console.log('matrix='+JSON.stringify({'include': testedVersions.map(mcVersion => ({mcVersion}))}))
" >> $GITHUB_OUTPUT
MinecraftServer:
needs: PrepareSupportedVersions
runs-on: ubuntu-latest
strategy:
matrix:
javaVersion: [1.8]
mcVersion: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5']
include:
- javaVersion: 16
mcVersion: '1.17.1'
- javaVersion: 17
mcVersion: '1.18.2'
- javaVersion: 17
mcVersion: '1.19'
- javaVersion: 17
mcVersion: '1.19.2'
- javaVersion: 17
mcVersion: '1.19.3'
- javaVersion: 17
mcVersion: '1.19.4'
- javaVersion: 17
mcVersion: '1.20.1'
matrix: ${{fromJson(needs.PrepareSupportedVersions.outputs.matrix)}}
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 18.x
uses: actions/setup-node@v1.4.4
with:
node-version: 14.x
node-version: 18.x
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: ${{ matrix.javaVersion }}
java-version: 17
java-package: jre
- name: Install Dependencies
run: npm install
- name: Start Tests
run: npm run mocha_test -- -g ${{ matrix.mcVersion }}
run: npm run mocha_test -- -g ${{ matrix.mcVersion }}v
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 14.0.0
node-version: 18.0.0
- id: publish
uses: JS-DevTools/npm-publish@v1
with:
Expand Down
11 changes: 0 additions & 11 deletions .gitpod.DockerFile

This file was deleted.

2 changes: 0 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
image:
file: .gitpod.DockerFile
tasks:
- command: npm install
74 changes: 60 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

[![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)

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

Create Minecraft bots with a powerful, stable, and high level JavaScript [API](api.md), also usable from Python.

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

## Features

* Supports Minecraft 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.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)
* 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 @@ -35,11 +35,16 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)

## Installation

First install Node.js >= 14 from [nodejs.org](https://nodejs.org/) then:
First install Node.js >= 18 from [nodejs.org](https://nodejs.org/) then:

`npm install mineflayer`
```bash
npm install mineflayer
```

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

## Documentation

Expand Down Expand Up @@ -80,11 +85,11 @@ const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
host: 'localhost', // minecraft server ip
username: 'email@example.com', // minecraft username
username: 'Bot', // username to join as if auth is `offline`, else a unique identifier for this account. Switch if you want to change accounts
auth: 'microsoft' // for offline mode servers, you can set this to 'offline'
// port: 25565, // only set if you need a port that isn't 25565
// 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
// password: '12345678' // set if you want to use password-based auth (may be unreliable)
// port: 25565, // set if you need a port that isn't 25565
// 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
// password: '12345678' // set if you want to use password-based auth (may be unreliable). If specified, the `username` must be an email
})

bot.on('chat', (username, message) => {
Expand All @@ -97,6 +102,27 @@ bot.on('kicked', console.log)
bot.on('error', console.log)
```

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,
the bot will automatically obtain and cache authentication tokens (under your specified username) so you don't have to sign-in again.

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

#### Connecting to a Realm

To join a Realm that your Minecraft account has been invited to, you can pass a `realms` object with a selector function like below.

```js
const client = mineflayer.createBot({
username: 'email@example.com', // minecraft username
realms: {
// This function is called with an array of Realms the account can join. It should return the one it wants to join.
pickRealm: (realms) => realms[0]
},
auth: 'microsoft'
})
```

### See what your bot is doing

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.
Expand Down Expand Up @@ -220,24 +246,44 @@ The most updated and useful are :
* [Chaoscraft](https://github.com/schematical/chaoscraft) - Minecraft bot using genetic algorithms, see [its youtube videos](https://www.youtube.com/playlist?list=PLLkpLgU9B5xJ7Qy4kOyBJl5J6zsDIMceH)
* [hexatester/minetelegram](https://github.com/hexatester/minetelegram) - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.
* [PrismarineJS/mineflayer-builder](https://github.com/PrismarineJS/mineflayer-builder) - Prints minecraft schematics in survival, keeping orientation
* [SilkePilon/OpenDeliveryBot](https://github.com/SilkePilon/OpenDeliveryBot) - Minecraft bot in python to deliver items from place to place.
* [and hundreds more](https://github.com/PrismarineJS/mineflayer/network/dependents) - All the projects that github detected are using mineflayer


## Testing

### Testing everything

Simply run: `npm test`
Simply run:

```bash
npm test
```

### Testing specific version
Run `npm run mocha_test -- -g <version>`, where `<version>` is a minecraft version like `1.12`, `1.15.2`...
Run

```bash
npm run mocha_test -- -g <version>
```

where `<version>` is a minecraft version like `1.12`, `1.15.2`...

### Testing specific test
Run `npm run mocha_test -- -g <test_name>`, where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...
Run

```bash
npm run mocha_test -- -g <test_name>
```

where `<test_name>` is a name of the test like `bed`, `useChests`, `rayTrace`...

### Example

`npm run mocha_test -- -g "1.18.1.*BlockFinder"` to run the block finder test for 1.18.1
```bash
npm run mocha_test -- -g "1.18.1.*BlockFinder"
```
to run the block finder test for 1.18.1

## License

Expand Down
Loading

0 comments on commit ab9d39a

Please sign in to comment.