mineflayer 4.1.0 → 4.4.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/README.md +6 -6
- package/docs/README.md +6 -6
- package/docs/api.md +75 -23
- package/docs/es/api_es.md +1 -1
- package/docs/history.md +36 -0
- package/docs/ru/README_RU.md +1 -2
- package/docs/ru/api_ru.md +2 -2
- package/docs/zh/api.md +1 -1
- package/examples/chatterbox.js +2 -3
- package/examples/chest.js +1 -1
- package/examples/discord.js +1 -1
- package/examples/inventory.js +1 -1
- package/index.d.ts +14 -9
- package/lib/bossbar.js +1 -1
- package/lib/loader.js +4 -4
- package/lib/plugins/bed.js +17 -3
- package/lib/plugins/block_actions.js +6 -5
- package/lib/plugins/book.js +4 -5
- package/lib/plugins/chat.js +3 -3
- package/lib/plugins/chest.js +7 -4
- package/lib/plugins/command_block.js +1 -1
- package/lib/plugins/craft.js +2 -2
- package/lib/plugins/creative.js +14 -12
- package/lib/plugins/entities.js +7 -8
- package/lib/plugins/fishing.js +2 -4
- package/lib/plugins/game.js +4 -1
- package/lib/plugins/generic_place.js +2 -2
- package/lib/plugins/inventory.js +54 -33
- package/lib/plugins/physics.js +4 -4
- package/lib/plugins/place_entity.js +2 -2
- package/lib/plugins/ray_trace.js +36 -0
- package/lib/plugins/settings.js +2 -2
- package/lib/plugins/tablist.js +1 -1
- package/lib/plugins/team.js +4 -1
- package/lib/plugins/villager.js +3 -3
- package/lib/scoreboard.js +1 -1
- package/lib/team.js +2 -2
- package/package.json +9 -9
- package/lib/features.json +0 -337
- package/lib/supportFeature.js +0 -27
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Mineflayer
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/mineflayer)
|
|
4
|
+
[](https://github.com/PrismarineJS/mineflayer/actions?query=workflow%3A%22CI%22)
|
|
5
|
+
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
6
|
+
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
7
7
|
[](https://github.com/sponsors/PrismarineJS)
|
|
8
8
|
|
|
9
|
-
[](https://discord.gg/GsEFRM8)
|
|
10
10
|
|
|
11
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) |
|
|
12
12
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
@@ -238,4 +238,4 @@ Run `npm run mocha_test -- -g <test_name>`, where `<test_name>` is a name of the
|
|
|
238
238
|
|
|
239
239
|
## License
|
|
240
240
|
|
|
241
|
-
[MIT](LICENSE)
|
|
241
|
+
[MIT](/LICENSE)
|
package/docs/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Mineflayer
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/mineflayer)
|
|
4
|
+
[](https://github.com/PrismarineJS/mineflayer/actions?query=workflow%3A%22CI%22)
|
|
5
|
+
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
6
|
+
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
7
7
|
[](https://github.com/sponsors/PrismarineJS)
|
|
8
8
|
|
|
9
|
-
[](https://discord.gg/GsEFRM8)
|
|
10
10
|
|
|
11
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) |
|
|
12
12
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
@@ -238,4 +238,4 @@ Run `npm run mocha_test -- -g <test_name>`, where `<test_name>` is a name of the
|
|
|
238
238
|
|
|
239
239
|
## License
|
|
240
240
|
|
|
241
|
-
[MIT](LICENSE)
|
|
241
|
+
[MIT](/LICENSE)
|
package/docs/api.md
CHANGED
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
- [Bot](#bot)
|
|
79
79
|
- [mineflayer.createBot(options)](#mineflayercreatebotoptions)
|
|
80
80
|
- [Properties](#properties)
|
|
81
|
+
- [bot.registry](#botregistry)
|
|
81
82
|
- [bot.world](#botworld)
|
|
82
83
|
- [world "blockUpdate" (oldBlock, newBlock)](#world-blockupdate-oldblock-newblock)
|
|
83
84
|
- [world "blockUpdate:(x, y, z)" (oldBlock, newBlock)](#world-blockupdatex-y-z-oldblock-newblock)
|
|
@@ -96,9 +97,10 @@
|
|
|
96
97
|
- [bot.game.serverBrand](#botgameserverbrand)
|
|
97
98
|
- [bot.game.minY](#botgameminy)
|
|
98
99
|
- [bot.game.height](#botgameheight)
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
- [bot.physicsEnabled](#botphysicsenabled)
|
|
101
|
+
- [bot.player](#botplayer)
|
|
101
102
|
- [bot.players](#botplayers)
|
|
103
|
+
- [bot.tablist](#bottablist)
|
|
102
104
|
- [bot.isRaining](#botisraining)
|
|
103
105
|
- [bot.rainState](#botrainstate)
|
|
104
106
|
- [bot.thunderState](#botthunderstate)
|
|
@@ -242,6 +244,7 @@
|
|
|
242
244
|
- [bot.waitForChunksToLoad()](#botwaitforchunkstoload)
|
|
243
245
|
- [bot.blockInSight(maxSteps, vectorLength)](#botblockinsightmaxsteps-vectorlength)
|
|
244
246
|
- [bot.blockAtCursor(maxDistance=256)](#botblockatcursormaxdistance256)
|
|
247
|
+
- [bot.entityAtCursor(maxDistance = 3.5)](#botentityatcursormaxdistance35)
|
|
245
248
|
- [bot.blockAtEntityCursor(entity=bot.entity, maxDistance=256)](#botblockatentitycursorentitybotentity-maxdistance256)
|
|
246
249
|
- [bot.canSeeBlock(block)](#botcanseeblockblock)
|
|
247
250
|
- [bot.findBlocks(options)](#botfindblocksoptions)
|
|
@@ -286,7 +289,7 @@
|
|
|
286
289
|
- [bot.denyResourcePack()](#botdenyresourcepack)
|
|
287
290
|
- [bot.placeBlock(referenceBlock, faceVector)](#botplaceblockreferenceblock-facevector)
|
|
288
291
|
- [bot.placeEntity(referenceBlock, faceVector)](#botplaceentityreferenceblock-facevector)
|
|
289
|
-
- [bot.activateBlock(block)](#botactivateblockblock)
|
|
292
|
+
- [bot.activateBlock(block, direction?: Vec3, cursorPos?: Vec3)](#botactivateblockblock-direction-vec3-cursorpos-vec3)
|
|
290
293
|
- [bot.activateEntity(entity)](#botactivateentityentity)
|
|
291
294
|
- [bot.activateEntityAt(entity, position)](#botactivateentityatentity-position)
|
|
292
295
|
- [bot.consume()](#botconsume)
|
|
@@ -302,8 +305,8 @@
|
|
|
302
305
|
- [bot.setQuickBarSlot(slot)](#botsetquickbarslotslot)
|
|
303
306
|
- [bot.craft(recipe, count, craftingTable)](#botcraftrecipe-count-craftingtable)
|
|
304
307
|
- [bot.writeBook(slot, pages)](#botwritebookslot-pages)
|
|
305
|
-
- [bot.openContainer(containerBlock or containerEntity)](#botopencontainercontainerblock-or-containerentity)
|
|
306
|
-
- [bot.openChest(chestBlock or minecartchestEntity)](#botopenchestchestblock-or-minecartchestentity)
|
|
308
|
+
- [bot.openContainer(containerBlock or containerEntity, direction?, cursorPos?)](#botopencontainercontainerblock-or-containerentity-direction-cursorpos)
|
|
309
|
+
- [bot.openChest(chestBlock or minecartchestEntity, direction?, cursorPos?)](#botopenchestchestblock-or-minecartchestentity-direction-cursorpos)
|
|
307
310
|
- [bot.openFurnace(furnaceBlock)](#botopenfurnacefurnaceblock)
|
|
308
311
|
- [bot.openDispenser(dispenserBlock)](#botopendispenserdispenserblock)
|
|
309
312
|
- [bot.openEnchantmentTable(enchantmentTableBlock)](#botopenenchantmenttableenchantmenttableblock)
|
|
@@ -319,13 +322,15 @@
|
|
|
319
322
|
- [bot.putAway(slot)](#botputawayslot)
|
|
320
323
|
- [bot.closeWindow(window)](#botclosewindowwindow)
|
|
321
324
|
- [bot.transfer(options)](#bottransferoptions)
|
|
322
|
-
- [bot.openBlock(block)](#botopenblockblock)
|
|
325
|
+
- [bot.openBlock(block, direction?: Vec3, cursorPos?: Vec3)](#botopenblockblock-direction-vec3-cursorpos-vec3)
|
|
323
326
|
- [bot.openEntity(entity)](#botopenentityentity)
|
|
324
327
|
- [bot.moveSlotItem(sourceSlot, destSlot)](#botmoveslotitemsourceslot-destslot)
|
|
325
328
|
- [bot.updateHeldItem()](#botupdatehelditem)
|
|
326
329
|
- [bot.getEquipmentDestSlot(destination)](#botgetequipmentdestslotdestination)
|
|
327
330
|
- [bot.creative](#botcreative)
|
|
328
331
|
- [bot.creative.setInventorySlot(slot, item)](#botcreativesetinventoryslotslot-item)
|
|
332
|
+
- [bot.creative.clearSlot(slot)](#botcreativeclearslotslot)
|
|
333
|
+
- [bot.creative.clearInventory()](#botcreativeclearinventory)
|
|
329
334
|
- [bot.creative.flyTo(destination)](#botcreativeflytodestination)
|
|
330
335
|
- [bot.creative.startFlying()](#botcreativestartflying)
|
|
331
336
|
- [bot.creative.stopFlying()](#botcreativestopflying)
|
|
@@ -449,7 +454,7 @@ See [prismarine-recipe](https://github.com/PrismarineJS/prismarine-recipe)
|
|
|
449
454
|
### mineflayer.Container
|
|
450
455
|
|
|
451
456
|
Extends windows.Window for chests, dispensers, etc...
|
|
452
|
-
See `bot.
|
|
457
|
+
See `bot.openContainer(chestBlock or minecartchestEntity)`.
|
|
453
458
|
|
|
454
459
|
### mineflayer.Furnace
|
|
455
460
|
|
|
@@ -758,6 +763,10 @@ Create and return an instance of the class bot.
|
|
|
758
763
|
|
|
759
764
|
### Properties
|
|
760
765
|
|
|
766
|
+
#### bot.registry
|
|
767
|
+
|
|
768
|
+
Instance of minecraft-data used by the bot. Pass this to constructors that expect an instance of minecraft-data, such as prismarine-block.
|
|
769
|
+
|
|
761
770
|
#### bot.world
|
|
762
771
|
|
|
763
772
|
A sync representation of the world. Check the doc at http://github.com/PrismarineJS/prismarine-world
|
|
@@ -823,11 +832,11 @@ minimum y of the world
|
|
|
823
832
|
|
|
824
833
|
world height
|
|
825
834
|
|
|
826
|
-
|
|
835
|
+
#### bot.physicsEnabled
|
|
827
836
|
|
|
828
837
|
Enable physics, default true.
|
|
829
838
|
|
|
830
|
-
|
|
839
|
+
#### bot.player
|
|
831
840
|
|
|
832
841
|
Bot's player object
|
|
833
842
|
```js
|
|
@@ -846,6 +855,17 @@ A player's ping starts at 0, you might have to wait a bit for the server to send
|
|
|
846
855
|
|
|
847
856
|
Map of username to people playing the game.
|
|
848
857
|
|
|
858
|
+
#### bot.tablist
|
|
859
|
+
|
|
860
|
+
bot's tablist object has two keys, `header` and `footer`.
|
|
861
|
+
|
|
862
|
+
```js
|
|
863
|
+
{
|
|
864
|
+
header: { toString: Function }, // ChatMessage object.
|
|
865
|
+
footer: { toString: Function } // ChatMessage object.
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
849
869
|
#### bot.isRaining
|
|
850
870
|
|
|
851
871
|
#### bot.rainState
|
|
@@ -1302,19 +1322,21 @@ Fires when a note block goes off somewhere.
|
|
|
1302
1322
|
* `isOpen`: number of players that have the chest open. 0 if it's closed
|
|
1303
1323
|
* `block2`: a Block instance, the other half of the block whose lid opened. null if it's not a double chest
|
|
1304
1324
|
|
|
1305
|
-
#### "blockBreakProgressObserved" (block, destroyStage)
|
|
1325
|
+
#### "blockBreakProgressObserved" (block, destroyStage, entity)
|
|
1306
1326
|
|
|
1307
1327
|
Fires when the client observes a block in the process of being broken.
|
|
1308
1328
|
|
|
1309
1329
|
* `block`: a Block instance, the block being broken
|
|
1310
1330
|
* `destroyStage`: integer corresponding to the destroy progress (0-9)
|
|
1331
|
+
* `entity`: the entity which is breaking the block.
|
|
1311
1332
|
|
|
1312
|
-
#### "blockBreakProgressEnd" (block)
|
|
1333
|
+
#### "blockBreakProgressEnd" (block, entity)
|
|
1313
1334
|
|
|
1314
1335
|
Fires when the client observes a block stops being broken.
|
|
1315
1336
|
This occurs whether the process was completed or aborted.
|
|
1316
1337
|
|
|
1317
1338
|
* `block`: a Block instance, the block no longer being broken
|
|
1339
|
+
* `entity`: the entity which has stopped breaking the block
|
|
1318
1340
|
|
|
1319
1341
|
#### "diggingCompleted" (block)
|
|
1320
1342
|
|
|
@@ -1458,6 +1480,11 @@ Returns the block at which bot is looking at or `null`
|
|
|
1458
1480
|
Returns the block at which bot is looking at or `null`
|
|
1459
1481
|
* `maxDistance` - The maximum distance the block can be from the eye, defaults to 256.
|
|
1460
1482
|
|
|
1483
|
+
#### bot.entityAtCursor(maxDistance=3.5)
|
|
1484
|
+
|
|
1485
|
+
Returns the entity at which bot is looking at or `null`
|
|
1486
|
+
* `maxDistance` - The maximum distance the entity can be from the eye, defaults to 3.5.
|
|
1487
|
+
|
|
1461
1488
|
#### bot.blockAtEntityCursor(entity=bot.entity, maxDistance=256)
|
|
1462
1489
|
|
|
1463
1490
|
Returns the block at which specific entity is looking at or `null`
|
|
@@ -1801,13 +1828,15 @@ This function returns a `Promise`, with `Entity` as its argument upon completion
|
|
|
1801
1828
|
|
|
1802
1829
|
The new block will be placed at `referenceBlock.position.plus(faceVector)`.
|
|
1803
1830
|
|
|
1804
|
-
#### bot.activateBlock(block)
|
|
1831
|
+
#### bot.activateBlock(block, direction?: Vec3, cursorPos?: Vec3)
|
|
1805
1832
|
|
|
1806
1833
|
This function returns a `Promise`, with `void` as its argument upon completion.
|
|
1807
1834
|
|
|
1808
1835
|
Punch a note block, open a door, etc.
|
|
1809
1836
|
|
|
1810
1837
|
* `block` - the block to activate
|
|
1838
|
+
* `direction` Optional defaults to `new Vec3(0, 1, 0)` (up). A vector off the direction the container block should be interacted with. Does nothing when a container entity is targeted.
|
|
1839
|
+
* `cursorPos` Optional defaults to `new Vec3(0.5, 0.5, 0.5)` (block center). The curos position when opening the block instance. This is send with the activate block packet. Does nothing when a container entity is targeted.
|
|
1811
1840
|
|
|
1812
1841
|
#### bot.activateEntity(entity)
|
|
1813
1842
|
|
|
@@ -1859,13 +1888,13 @@ use shears.
|
|
|
1859
1888
|
Attack a player or a mob.
|
|
1860
1889
|
|
|
1861
1890
|
* `entity` is a type of entity. To get a specific entity use [bot.nearestEntity()](#botnearestentitymatch--entity---return-true-) or [bot.entities](#botentities).
|
|
1862
|
-
* `swing` Default `true`. If false the bot does not swing
|
|
1891
|
+
* `swing` Default to `true`. If false the bot does not swing its arm when attacking.
|
|
1863
1892
|
|
|
1864
1893
|
#### bot.swingArm([hand], showHand)
|
|
1865
1894
|
|
|
1866
1895
|
Play an arm swing animation.
|
|
1867
1896
|
|
|
1868
|
-
* `hand` can take `left` or `right` which is arm that is animated. Default: `right`
|
|
1897
|
+
* `hand` can take `left` or `right` which is the arm that is animated. Default: `right`
|
|
1869
1898
|
* `showHand` is a boolean whether to add the hand to the packet, Default: `true`
|
|
1870
1899
|
|
|
1871
1900
|
#### bot.mount(entity)
|
|
@@ -1908,11 +1937,16 @@ This function returns a `Promise`, with `void` as its argument when the writing
|
|
|
1908
1937
|
* `slot` is in inventory window coordinates (where 36 is the first quickbar slot, etc.).
|
|
1909
1938
|
* `pages` is an array of strings represents the pages.
|
|
1910
1939
|
|
|
1911
|
-
#### bot.openContainer(containerBlock or containerEntity)
|
|
1940
|
+
#### bot.openContainer(containerBlock or containerEntity, direction?, cursorPos?)
|
|
1941
|
+
Opens a block container or entity.
|
|
1942
|
+
|
|
1943
|
+
* `containerBlock` or `containerEntity` The block instance to open or the entity to open.
|
|
1944
|
+
* `direction` Optional defaults to `new Vec3(0, 1, 0)` (up). A vector off the direction the container block should be interacted with. Does nothing when a container entity is targeted.
|
|
1945
|
+
* `cursorPos` Optional defaults to `new Vec3(0.5, 0.5, 0.5)` (block center). The curos position when opening the block instance. This is send with the activate block packet. Does nothing when a container entity is targeted.
|
|
1912
1946
|
|
|
1913
1947
|
Returns a promise on a `Container` instance which represents the container you are opening.
|
|
1914
1948
|
|
|
1915
|
-
#### bot.openChest(chestBlock or minecartchestEntity)
|
|
1949
|
+
#### bot.openChest(chestBlock or minecartchestEntity, direction?, cursorPos?)
|
|
1916
1950
|
|
|
1917
1951
|
Deprecated. Same as `openContainer`
|
|
1918
1952
|
|
|
@@ -1976,9 +2010,13 @@ These are lower level methods for the inventory, they can be useful sometimes bu
|
|
|
1976
2010
|
#### bot.clickWindow(slot, mouseButton, mode)
|
|
1977
2011
|
|
|
1978
2012
|
This function returns a `Promise`, with `void` as its argument upon completion.
|
|
2013
|
+
|
|
2014
|
+
The only valid mode option at the moment is 0. Shift clicking or mouse draging is not implemented.
|
|
1979
2015
|
|
|
1980
2016
|
Click on the current window. See details at https://wiki.vg/Protocol#Click_Window
|
|
1981
2017
|
|
|
2018
|
+
Prefer using bot.simpleClick.*
|
|
2019
|
+
|
|
1982
2020
|
#### bot.putSelectedItemRange(start, end, window, slot)
|
|
1983
2021
|
|
|
1984
2022
|
This function returns a `Promise`, with `void` as its argument upon completion.
|
|
@@ -2001,19 +2039,21 @@ This function returns a `Promise`, with `void` as its argument upon completion.
|
|
|
2001
2039
|
|
|
2002
2040
|
Transfer some kind of item from one range to an other. `options` is an object containing :
|
|
2003
2041
|
|
|
2004
|
-
* `window` : the window where the item will be moved
|
|
2042
|
+
* `window` : Optional. the window where the item will be moved
|
|
2005
2043
|
* `itemType` : the type of the moved items
|
|
2006
|
-
* `metadata` : the metadata of the moved items
|
|
2007
|
-
* `sourceStart` and `sourceEnd` : the source range
|
|
2008
|
-
* `destStart` and `destEnd` : the dest Range
|
|
2044
|
+
* `metadata` : Optional. the metadata of the moved items
|
|
2045
|
+
* `sourceStart` and `sourceEnd` : the source range. `sourceEnd` is optional and will default to `sourceStart` + 1
|
|
2046
|
+
* `destStart` and `destEnd` : the dest Range. `destEnd` is optional and will default to `destStart` + 1
|
|
2009
2047
|
* `count` : the amount of items to transfer. Default: `1`
|
|
2010
2048
|
* `nbt` : nbt data of the item to transfer. Default: `nullish` (ignores nbt)
|
|
2011
2049
|
|
|
2012
|
-
#### bot.openBlock(block)
|
|
2050
|
+
#### bot.openBlock(block, direction?: Vec3, cursorPos?: Vec3)
|
|
2013
2051
|
|
|
2014
2052
|
Open a block, for example a chest, returns a promise on the opening `Window`.
|
|
2015
2053
|
|
|
2016
|
-
* `block` is the block the bot will open
|
|
2054
|
+
* `block` is the block the bot will open.
|
|
2055
|
+
* `direction` Optional defaults to `new Vec3(0, 1, 0)` (up). A vector off the direction the container block should be interacted with. Does nothing when a container entity is targeted.
|
|
2056
|
+
* `cursorPos` Optional defaults to `new Vec3(0.5, 0.5, 0.5)` (block center). The curos position when opening the block instance. This is send with the activate block packet. Does nothing when a container entity is targeted.
|
|
2017
2057
|
|
|
2018
2058
|
#### bot.openEntity(entity)
|
|
2019
2059
|
|
|
@@ -2051,7 +2091,7 @@ but it is assumed and often required that the bot be in creative mode for these
|
|
|
2051
2091
|
|
|
2052
2092
|
#### bot.creative.setInventorySlot(slot, item)
|
|
2053
2093
|
|
|
2054
|
-
This function returns a `Promise`, with `void` as its argument when gets fired when the
|
|
2094
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server sets the slot.
|
|
2055
2095
|
|
|
2056
2096
|
Gives the bot the specified item in the specified inventory slot.
|
|
2057
2097
|
|
|
@@ -2061,6 +2101,18 @@ Gives the bot the specified item in the specified inventory slot.
|
|
|
2061
2101
|
|
|
2062
2102
|
If this method changes anything, you can be notified via `bot.inventory.on("updateSlot")`.
|
|
2063
2103
|
|
|
2104
|
+
#### bot.creative.clearSlot(slot)
|
|
2105
|
+
|
|
2106
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server clears the slot.
|
|
2107
|
+
|
|
2108
|
+
Makes the sets the item in the slot given to null.
|
|
2109
|
+
|
|
2110
|
+
* `slot` is in inventory window coordinates (where 36 is the first quickbar slot, etc.).
|
|
2111
|
+
|
|
2112
|
+
#### bot.creative.clearInventory()
|
|
2113
|
+
|
|
2114
|
+
This function returns a `Promise`, with `void` as its argument when gets fired when the server clears the slot.
|
|
2115
|
+
|
|
2064
2116
|
#### bot.creative.flyTo(destination)
|
|
2065
2117
|
|
|
2066
2118
|
This function returns a `Promise`, with `void` as its argument when the bot arrives at the destination.
|
package/docs/es/api_es.md
CHANGED
|
@@ -423,7 +423,7 @@ Mira [prismarine-recipe](https://github.com/PrismarineJS/prismarine-recipe)
|
|
|
423
423
|
### mineflayer.Container
|
|
424
424
|
|
|
425
425
|
Extiende windows.Window para cofres, dispensadores, etc...
|
|
426
|
-
Mira `bot.
|
|
426
|
+
Mira `bot.openContainer(chestBlock o minecartchestEntity)`.
|
|
427
427
|
|
|
428
428
|
### mineflayer.Furnace
|
|
429
429
|
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 4.4.0
|
|
2
|
+
|
|
3
|
+
* Fix chatterbox example not getting dropped item
|
|
4
|
+
* Fix 404d link to license [#2601](https://github.com/PrismarineJS/mineflayer/pull/2601)
|
|
5
|
+
* Add bot.clickWindow mode disclaimer [#2595](https://github.com/PrismarineJS/mineflayer/pull/2595)
|
|
6
|
+
* Add spectator to GameMode types [#2627](https://github.com/PrismarineJS/mineflayer/pull/2627)
|
|
7
|
+
* Update types for isABed [#2628](https://github.com/PrismarineJS/mineflayer/pull/2628)
|
|
8
|
+
* Replace openChest with openContainer in docs and examples [#2656](https://github.com/PrismarineJS/mineflayer/pull/2656)
|
|
9
|
+
* Add ender chests as a chest type [#2642](https://github.com/PrismarineJS/mineflayer/pull/2642)
|
|
10
|
+
* Added method to wait until sleep function is in reality sleeping [#2617](https://github.com/PrismarineJS/mineflayer/pull/2617)
|
|
11
|
+
* Added type on move event [#2712](https://github.com/PrismarineJS/mineflayer/pull/2712)
|
|
12
|
+
* Added thunderState type [#2711](https://github.com/PrismarineJS/mineflayer/pull/2711)
|
|
13
|
+
* Fix type error on chest open [#2684](https://github.com/PrismarineJS/mineflayer/pull/2684)
|
|
14
|
+
* Add support for repeating and chain command blocks. [#2669](https://github.com/PrismarineJS/mineflayer/pull/2669)
|
|
15
|
+
* Add player object to blockBreakProgressEnd & observed. [#2647](https://github.com/PrismarineJS/mineflayer/pull/2647)
|
|
16
|
+
* Add entity to blockBreakProgress [#2648](https://github.com/PrismarineJS/mineflayer/pull/2648)
|
|
17
|
+
* Add direction support to activateBlock, openBlock [#2039](https://github.com/PrismarineJS/mineflayer/pull/2039)
|
|
18
|
+
* Add entityAtCursor function [#2077](https://github.com/PrismarineJS/mineflayer/pull/2077)
|
|
19
|
+
* Fix regex dos [#2350](https://github.com/PrismarineJS/mineflayer/pull/2350)
|
|
20
|
+
|
|
21
|
+
## 4.3.0
|
|
22
|
+
|
|
23
|
+
* Cache 'positionUpdateSentEveryTick' feature lookup (@IceTank)
|
|
24
|
+
* Remove old teams from bot.teamMap (@U9G)
|
|
25
|
+
* mcdata 3.0.0
|
|
26
|
+
|
|
27
|
+
## 4.2.0
|
|
28
|
+
|
|
29
|
+
* add missing extraInfos argument to Bot.blockAt function (@dumbasPL)
|
|
30
|
+
* Emit window close event AFTER updating the inventory (@imharvol)
|
|
31
|
+
* Move supportFeature to mcdata (@U9G)
|
|
32
|
+
* Update lib/ and test/ to use prismarine-registry (@extremeheat)
|
|
33
|
+
* only open chests with openContainer (@U9G)
|
|
34
|
+
* Add bot.creative.clearSlot and bot.creative.clearInventory (@U9G)
|
|
35
|
+
* remove transaction warning
|
|
36
|
+
|
|
1
37
|
## 4.1.0
|
|
2
38
|
|
|
3
39
|
* 1.18.2 support
|
package/docs/ru/README_RU.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
## Возможности
|
|
20
20
|
|
|
21
|
-
* Поддержка 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 и 1.
|
|
21
|
+
* Поддержка 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 и 1.18
|
|
22
22
|
* Поддержка энтити и их отслеживание
|
|
23
23
|
* Вы можете полностью взаимодействовать с миром. Миллисекунды на поиск любого блока
|
|
24
24
|
* Физика и управление
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
| -------------------------------------------------------------------------- | ------------------------------------- |
|
|
47
47
|
| [Обучение](tutorial.md) | Знакомство с Node.js и Mineflayer |
|
|
48
48
|
| [FAQ](FAQ_RU.md) | Появился вопрос? Найдите ответ здесь. |
|
|
49
|
-
| [API](api_ru.md) | Методы API |
|
|
50
49
|
| [Нестабильное API](unstable_api_ru.md) | Нестабильные методы API |
|
|
51
50
|
| [Обновления](history.md) | Список изменений в обновлениях |
|
|
52
51
|
| [Примеры](https://github.com/PrismarineJS/mineflayer/tree/master/examples) | Примеры использования Mineflayer |
|
package/docs/ru/api_ru.md
CHANGED
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
### mineflayer.Chest
|
|
369
369
|
|
|
370
370
|
Предоставляет сеанс взаимодействия с сундуками ( Открытие и закрытие )
|
|
371
|
-
Смотрите `bot.
|
|
371
|
+
Смотрите `bot.openContainer(chestBlock or minecartchestEntity)`.
|
|
372
372
|
|
|
373
373
|
#### chest.window
|
|
374
374
|
|
|
@@ -1490,7 +1490,7 @@ bot.once('login', () => {
|
|
|
1490
1490
|
|
|
1491
1491
|
#### bot.openChest(chestBlock or minecartchestEntity)
|
|
1492
1492
|
|
|
1493
|
-
|
|
1493
|
+
Устарело.Открывает сундук. Такой же как "openContainer"
|
|
1494
1494
|
|
|
1495
1495
|
#### bot.openFurnace(furnaceBlock)
|
|
1496
1496
|
|
package/docs/zh/api.md
CHANGED
|
@@ -446,7 +446,7 @@ See [prismarine-recipe](https://github.com/PrismarineJS/prismarine-recipe)
|
|
|
446
446
|
### mineflayer.Container
|
|
447
447
|
|
|
448
448
|
Extends windows.Window for chests, dispensers, etc...
|
|
449
|
-
See `bot.
|
|
449
|
+
See `bot.openContainer(chestBlock or minecartchestEntity)`.
|
|
450
450
|
|
|
451
451
|
### mineflayer.Furnace
|
|
452
452
|
|
package/examples/chatterbox.js
CHANGED
|
@@ -168,9 +168,8 @@ bot.on('playerLeft', (player) => {
|
|
|
168
168
|
bot.chat(`Bye ${player.username}`)
|
|
169
169
|
})
|
|
170
170
|
bot.on('playerCollect', (collector, collected) => {
|
|
171
|
-
if (collector.type === 'player'
|
|
172
|
-
const
|
|
173
|
-
const item = mineflayer.Item.fromNotch(rawItem)
|
|
171
|
+
if (collector.type === 'player') {
|
|
172
|
+
const item = collected.getDroppedItem()
|
|
174
173
|
bot.chat(`${collector.username !== bot.username ? ("I'm so jealous. " + collector.username) : 'I '} collected ${item.count} ${item.displayName}`)
|
|
175
174
|
}
|
|
176
175
|
})
|
package/examples/chest.js
CHANGED
|
@@ -103,7 +103,7 @@ async function watchChest (minecart, blocks = []) {
|
|
|
103
103
|
return
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const chest = await bot.
|
|
106
|
+
const chest = await bot.openContainer(chestToOpen)
|
|
107
107
|
sayItems(chest.containerItems())
|
|
108
108
|
chest.on('updateSlot', (slot, oldItem, newItem) => {
|
|
109
109
|
bot.chat(`chest update: ${itemToString(oldItem)} -> ${itemToString(newItem)} (slot: ${slot})`)
|
package/examples/discord.js
CHANGED
package/examples/inventory.js
CHANGED
|
@@ -129,7 +129,7 @@ async function craftItem (name, amount) {
|
|
|
129
129
|
amount = parseInt(amount, 10)
|
|
130
130
|
const mcData = require('minecraft-data')(bot.version)
|
|
131
131
|
|
|
132
|
-
const item = mcData.
|
|
132
|
+
const item = mcData.itemsByName[name]
|
|
133
133
|
const craftingTableID = mcData.blocksByName.crafting_table.id
|
|
134
134
|
|
|
135
135
|
const craftingTable = bot.findBlock({
|
package/index.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ interface BotEvents {
|
|
|
126
126
|
blockBreakProgressEnd: (block: Block) => Promise<void> | void
|
|
127
127
|
diggingCompleted: (block: Block) => Promise<void> | void
|
|
128
128
|
diggingAborted: (block: Block) => Promise<void> | void
|
|
129
|
-
move: () => Promise<void> | void
|
|
129
|
+
move: (position: Vec3) => Promise<void> | void
|
|
130
130
|
forcedMove: () => Promise<void> | void
|
|
131
131
|
mount: () => Promise<void> | void
|
|
132
132
|
dismount: (vehicle: Entity) => Promise<void> | void
|
|
@@ -165,6 +165,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
165
165
|
player: Player
|
|
166
166
|
players: { [username: string]: Player }
|
|
167
167
|
isRaining: boolean
|
|
168
|
+
thunderState: number
|
|
168
169
|
chatPatterns: ChatPattern[]
|
|
169
170
|
settings: GameSettings
|
|
170
171
|
experience: Experience
|
|
@@ -197,7 +198,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
197
198
|
|
|
198
199
|
end: (reason?: string) => void
|
|
199
200
|
|
|
200
|
-
blockAt: (point: Vec3) => Block | null
|
|
201
|
+
blockAt: (point: Vec3, extraInfos?: boolean) => Block | null
|
|
201
202
|
|
|
202
203
|
blockInSight: (maxSteps: number, vectorLength: number) => Block | null
|
|
203
204
|
|
|
@@ -249,7 +250,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
249
250
|
|
|
250
251
|
sleep: (bedBlock: Block) => Promise<void>
|
|
251
252
|
|
|
252
|
-
isABed: (bedBlock: Block) =>
|
|
253
|
+
isABed: (bedBlock: Block) => boolean
|
|
253
254
|
|
|
254
255
|
wake: () => Promise<void>
|
|
255
256
|
|
|
@@ -294,11 +295,11 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
294
295
|
|
|
295
296
|
digTime: (block: Block) => number
|
|
296
297
|
|
|
297
|
-
placeBlock: (referenceBlock: Block, faceVector: Vec3
|
|
298
|
+
placeBlock: (referenceBlock: Block, faceVector: Vec3) => Promise<void>
|
|
298
299
|
|
|
299
300
|
placeEntity: (referenceBlock: Block, faceVector: Vec3) => Promise<Entity>
|
|
300
301
|
|
|
301
|
-
activateBlock: (block: Block) => Promise<void>
|
|
302
|
+
activateBlock: (block: Block, direction?: Vec3, cursorPos?: Vec3) => Promise<void>
|
|
302
303
|
|
|
303
304
|
activateEntity: (block: Entity) => Promise<void>
|
|
304
305
|
|
|
@@ -337,9 +338,9 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
337
338
|
pages: string[]
|
|
338
339
|
) => Promise<void>
|
|
339
340
|
|
|
340
|
-
openContainer: (chest: Block | Entity) => Promise<Chest | Furnace | Dispenser>
|
|
341
|
+
openContainer: (chest: Block | Entity, direction?: Vec3, cursorPos?: Vec3) => Promise<Chest | Furnace | Dispenser>
|
|
341
342
|
|
|
342
|
-
openChest: (chest: Block | Entity) => Promise<Chest>
|
|
343
|
+
openChest: (chest: Block | Entity, direction?: number, cursorPos?: Vec3) => Promise<Chest>
|
|
343
344
|
|
|
344
345
|
openFurnace: (furnace: Block) => Promise<Furnace>
|
|
345
346
|
|
|
@@ -380,7 +381,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
380
381
|
|
|
381
382
|
transfer: (options: TransferOptions) => Promise<void>
|
|
382
383
|
|
|
383
|
-
openBlock: (block: Block,
|
|
384
|
+
openBlock: (block: Block, direction?: Vec3, cursorPos?: Vec3) => Promise<void>
|
|
384
385
|
|
|
385
386
|
openEntity: (block: Entity, Class: new () => EventEmitter) => Promise<void>
|
|
386
387
|
|
|
@@ -444,7 +445,7 @@ export type LevelType =
|
|
|
444
445
|
| 'customized'
|
|
445
446
|
| 'buffet'
|
|
446
447
|
| 'default_1_1'
|
|
447
|
-
export type GameMode = 'survival' | 'creative' | 'adventure'
|
|
448
|
+
export type GameMode = 'survival' | 'creative' | 'adventure' | 'spectator'
|
|
448
449
|
export type Dimension = 'minecraft:nether' | 'minecraft:overworld' | 'minecraft:end'
|
|
449
450
|
export type Difficulty = 'peaceful' | 'easy' | 'normal' | 'hard'
|
|
450
451
|
|
|
@@ -571,6 +572,10 @@ export interface creativeMethods {
|
|
|
571
572
|
item: Item | null
|
|
572
573
|
) => Promise<void>
|
|
573
574
|
|
|
575
|
+
clearSlot: (slot: number) => Promise<void>
|
|
576
|
+
|
|
577
|
+
clearInventory: () => Promise<void>
|
|
578
|
+
|
|
574
579
|
flyTo: (destination: Vec3) => Promise<void>
|
|
575
580
|
|
|
576
581
|
startFlying: () => void
|
package/lib/bossbar.js
CHANGED
|
@@ -5,7 +5,7 @@ const divisions = [0, 6, 10, 12, 20]
|
|
|
5
5
|
module.exports = loader
|
|
6
6
|
|
|
7
7
|
function loader (mcVersion) {
|
|
8
|
-
ChatMessage = require('prismarine-chat')(mcVersion)
|
|
8
|
+
ChatMessage = require('prismarine-chat')(mcVersion) // TODO: update for prismarine-registry
|
|
9
9
|
return BossBar
|
|
10
10
|
}
|
|
11
11
|
|
package/lib/loader.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const mc = require('minecraft-protocol')
|
|
2
2
|
const { EventEmitter } = require('events')
|
|
3
3
|
const pluginLoader = require('./plugin_loader')
|
|
4
|
-
const supportFeature = require('./supportFeature')
|
|
5
4
|
const plugins = {
|
|
6
5
|
bed: require('./plugins/bed'),
|
|
7
6
|
title: require('./plugins/title'),
|
|
@@ -56,7 +55,7 @@ module.exports = {
|
|
|
56
55
|
BossBar: require('./bossbar'),
|
|
57
56
|
supportedVersions,
|
|
58
57
|
testedVersions,
|
|
59
|
-
supportFeature
|
|
58
|
+
supportFeature: (feature, version) => require('minecraft-data')(version).supportFeature(feature)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
function createBot (options = {}) {
|
|
@@ -105,7 +104,8 @@ function createBot (options = {}) {
|
|
|
105
104
|
if (!bot._client.wait_connect) next()
|
|
106
105
|
else bot._client.once('connect_allowed', next)
|
|
107
106
|
function next () {
|
|
108
|
-
|
|
107
|
+
bot.registry = require('prismarine-registry')(bot._client.version)
|
|
108
|
+
const version = bot.registry.version
|
|
109
109
|
if (supportedVersions.indexOf(version.majorVersion) === -1) {
|
|
110
110
|
throw new Error(`Version ${version.minecraftVersion} is not supported.`)
|
|
111
111
|
}
|
|
@@ -120,7 +120,7 @@ function createBot (options = {}) {
|
|
|
120
120
|
bot.majorVersion = version.majorVersion
|
|
121
121
|
bot.version = version.minecraftVersion
|
|
122
122
|
options.version = version.minecraftVersion
|
|
123
|
-
bot.supportFeature =
|
|
123
|
+
bot.supportFeature = bot.registry.supportFeature
|
|
124
124
|
bot.emit('inject_allowed')
|
|
125
125
|
}
|
|
126
126
|
return bot
|
package/lib/plugins/bed.js
CHANGED
|
@@ -6,7 +6,6 @@ const CARDINAL_DIRECTIONS = ['south', 'west', 'north', 'east']
|
|
|
6
6
|
|
|
7
7
|
function inject (bot) {
|
|
8
8
|
bot.isSleeping = false
|
|
9
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
10
9
|
|
|
11
10
|
const beds = new Set(['white_bed', 'orange_bed', 'magenta_bed', 'light_blue_bed', 'yellow_bed', 'lime_bed', 'pink_bed', 'gray_bed',
|
|
12
11
|
'light_gray_bed', 'cyan_bed', 'purple_bed', 'blue_bed', 'brown_bed', 'green_bed', 'red_bed', 'black_bed', 'bed'])
|
|
@@ -24,7 +23,7 @@ function inject (bot) {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (bot.supportFeature('blockStateId')) {
|
|
27
|
-
const state = bedBlock.stateId -
|
|
26
|
+
const state = bedBlock.stateId - bot.registry.blocksByStateId[bedBlock.stateId].minStateId
|
|
28
27
|
const bitMetadata = state.toString(2).padStart(4, '0') // FACING (first 2 bits), PART (3rd bit), OCCUPIED (4th bit)
|
|
29
28
|
metadata.part = bitMetadata[3] === '0'
|
|
30
29
|
metadata.occupied = bitMetadata[2] === '0'
|
|
@@ -147,10 +146,25 @@ function inject (bot) {
|
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
|
|
149
|
+
bot.activateBlock(bedBlock)
|
|
150
|
+
|
|
151
|
+
await waitUntilSleep()
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
async function waitUntilSleep () {
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
const timeoutForSleep = setTimeout(() => {
|
|
158
|
+
reject(new Error('bot is not sleeping'))
|
|
159
|
+
}, 3000)
|
|
160
|
+
|
|
161
|
+
bot.once('sleep', () => {
|
|
162
|
+
clearTimeout(timeoutForSleep)
|
|
163
|
+
resolve()
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
154
168
|
bot._client.on('game_state_change', (packet) => {
|
|
155
169
|
if (packet.reason === 0) {
|
|
156
170
|
// occurs when you can't spawn in your bed and your spawn point gets reset
|