mineflayer 4.5.1 → 4.6.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/docs/api.md CHANGED
@@ -75,6 +75,14 @@
75
75
  - [BossBar.isDragonBar](#bossbarisdragonbar)
76
76
  - [BossBar.createFog](#bossbarcreatefog)
77
77
  - [BossBar.color](#bossbarcolor)
78
+ - [mineflayer.Particle](#mineflayerparticle)
79
+ - [Particle.id](#particleid)
80
+ - [Particle.name](#particlename)
81
+ - [Particle.position](#particleposition)
82
+ - [Particle.offset](#particleoffset)
83
+ - [Particle.longDistanceRender](#particlelongdistancerender)
84
+ - [Particle.count](#particlecount)
85
+ - [Particle.movementSpeed](#particlemovementspeed)
78
86
  - [Bot](#bot)
79
87
  - [mineflayer.createBot(options)](#mineflayercreatebotoptions)
80
88
  - [Properties](#properties)
@@ -239,6 +247,7 @@
239
247
  - ["heldItemChanged" (heldItem)](#helditemchanged-helditem)
240
248
  - ["physicsTick" ()](#physicstick-)
241
249
  - ["chat:name" (matches)](#chatname-matches)
250
+ - ["particle"](#particle)
242
251
  - [Functions](#functions)
243
252
  - [bot.blockAt(point, extraInfos=true)](#botblockatpoint-extrainfostrue)
244
253
  - [bot.waitForChunksToLoad()](#botwaitforchunkstoload)
@@ -725,6 +734,36 @@ Determines whether or not boss bar creates fog
725
734
 
726
735
  Determines what color the boss bar color is, one of `pink`, `blue`, `red`, `green`, `yellow`, `purple`, `white`
727
736
 
737
+ ### mineflayer.Particle
738
+
739
+ #### Particle.id
740
+
741
+ Particle ID, as defined in the [protocol](https://wiki.vg/Protocol#Particle)
742
+
743
+ #### Particle.name
744
+
745
+ Particle Name, as defined in the [protocol](https://wiki.vg/Protocol#Particle)
746
+
747
+ #### Particle.position
748
+
749
+ Vec3 instance of where the particle was created
750
+
751
+ #### Particle.offset
752
+
753
+ Vec3 instance of the particle's offset
754
+
755
+ #### Particle.longDistanceRender
756
+
757
+ Determines whether or not to force the rendering of a particle despite client particle settings and increases maximum view distance from 256 to 65536
758
+
759
+ #### Particle.count
760
+
761
+ Amount of particles created
762
+
763
+ #### Particle.movementSpeed
764
+
765
+ Particle speed in a random direction
766
+
728
767
  ## Bot
729
768
 
730
769
  ### mineflayer.createBot(options)
@@ -1465,6 +1504,10 @@ Fires every tick if bot.physicsEnabled is set to true.
1465
1504
 
1466
1505
  Fires when the all of a chat pattern's regexs have matches
1467
1506
 
1507
+ #### "particle"
1508
+
1509
+ Fires when a particle is created
1510
+
1468
1511
  ### Functions
1469
1512
 
1470
1513
  #### bot.blockAt(point, extraInfos=true)
@@ -17,7 +17,7 @@ Crea bots para Minecraft con una API de JavaScript potente, estable y de alto ni
17
17
 
18
18
  ## Características
19
19
 
20
- * Soporta Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 y 1.18.
20
+ * Soporta Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18 y 1.19.
21
21
  * Rastreo e información de entidades.
22
22
  * Información sobre bloques. Puedes solicitar información de todo lo que te rodea. Encuentra bloques en milisegundos
23
23
  * Físicas y movimientos básicos - maneja todos los cuadros de colisión
@@ -0,0 +1,182 @@
1
+ ## FAQ
2
+
3
+ Ce document de foire aux questions a pour but d'aider les gens pour les choses les plus courantes.
4
+
5
+ ### Je reçois une erreur lorsque j'essaie de me connecter avec un compte Microsoft.
6
+
7
+ Assurez-vous que l'email que vous avez entré dans l'option username de createBot peut être utilisé pour vous connecter à `minecraft.net` en utilisant le bouton 'Login with Microsoft'.
8
+ Assurez-vous que vous avez l'option `auth : 'microsoft'` dans vos options createBot.
9
+
10
+ Lorsque vous obtenez une erreur qui dit quelque chose au sujet des informations d'identification invalides ou "Ce compte possède Minecraft ?", essayez de supprimer le champ du mot de passe dans les options `createBot` et réessayez.
11
+
12
+ ### Comment masquer les erreurs ?
13
+
14
+ Utiliser `hideErrors : true` dans les options de createBot
15
+ Vous pouvez également choisir d'ajouter ces listeners :
16
+
17
+ ```js
18
+ client.on('error', () => {})
19
+ client.on('end', () => {})
20
+ ```
21
+
22
+ ### Je ne reçois pas d'événement de chat sur un serveur personnalisé, comment puis-je résoudre ce problème ?
23
+
24
+ Les serveurs Spigot, en particulier certains plugins, utilisent des formats de chat personnalisés, vous devez les analyser avec une expression rationnelle / un analyseur syntaxique personnalisé.
25
+ Lisez et adaptez [chat_parsing.js](https://github.com/PrismarineJS/mineflayer/blob/master/examples/chat_parsing.js) pour qu'il fonctionne pour vos besoins particuliers.
26
+ plugin de chat. A lire également <http://mineflayer.prismarine.js.org/#/tutorial?id=custom-chat>
27
+
28
+ ### Comment puis-je collecter les informations d'un plugin personnalisé dans le chat ?
29
+
30
+ La plupart des serveurs Minecraft personnalisés ont le support des plugins, et beaucoup de ces plugins disent quelque chose dans le chat quand quelque chose se passe. Si c'est juste un message, il est préférable d'utiliser la solution discutée dans la solution ci-dessus, mais quand ces messages sont divisés en plusieurs petits messages, une autre option est d'utiliser l'événement `"messagestr"` car il permet d'analyser facilement les messages de plusieurs lignes.
31
+
32
+ **Exemple:**
33
+
34
+ Le message du chat dans le chat ressemble à ceci :
35
+
36
+ ```
37
+ (!) U9G has won the /jackpot and received
38
+ $26,418,402,450! They purchased 2,350,000 (76.32%) ticket(s) out of the
39
+ 3,079,185 ticket(s) sold!
40
+ ```
41
+
42
+ ```js
43
+ const regex = {
44
+ first: /\(!\) (.+) has won the \/jackpot and received +/,
45
+ second: /\$(.+)! They purchased (.+) \((.+)%\) ticket\(s\) out of the /,
46
+ third: /(.+) ticket\(s\) sold!/
47
+ }
48
+
49
+ let jackpot = {}
50
+ bot.on('messagestr', msg => {
51
+ if (regex.first.test(msg)) {
52
+ const username = msg.match(regex.first)[1]
53
+ jackpot.username = username
54
+ } else if (regex.second.test(msg)) {
55
+ const [, moneyWon, boughtTickets, winPercent] = msg.match(regex.second)
56
+ jackpot.moneyWon = parseInt(moneyWon.replace(/,/g, ''))
57
+ jackpot.boughtTickets = parseInt(boughtTickets.replace(/,/g, ''))
58
+ jackpot.winPercent = parseFloat(winPercent)
59
+ } else if (regex.third.test(msg)) {
60
+ const totalTickets = msg.match(regex.third)[1]
61
+ jackpot.totalTickets = parseInt(totalTickets.replace(/,/g, ''))
62
+ onDone(jackpot)
63
+ jackpot = {}
64
+ }
65
+ })
66
+ ```
67
+
68
+ ### Comment puis-je envoyer une commande ?
69
+
70
+ En utilisant `bot.chat()`.
71
+
72
+ **Example:**
73
+
74
+ ```js
75
+ bot.chat('/give @p diamond')
76
+ ```
77
+
78
+ ### Est-il possible de se connecter à plusieurs comptes en utilisant bot = mineflayer.createbot tout en les contrôlant tous séparément ?
79
+
80
+ Créer différentes instances de bot en appelant createBot puis faire différentes choses pour chacune, voir multiple.js
81
+
82
+ ### Comment faire pour que le robot lâche tout son inventaire ?
83
+
84
+ bot.inventory.items() renvoie un tableau des objets du bot. Vous pouvez utiliser une fonction récursive pour les parcourir en boucle et déposer chaque objet en utilisant bot.toss(). Cliquez [ici](https://gist.github.com/dada513/3d88f772be4224b40f9e5d1787bd63e9) pour voir un exemple.
85
+
86
+ ### Comment vérifier les paquets qui sont envoyés/reçus ?
87
+
88
+ Activation du mode de débogage <https://github.com/PrismarineJS/mineflayer#debug>
89
+
90
+ ### Je veux éviter la déconnexion même en cas de lag du serveur, comment puis-je y parvenir ?
91
+
92
+ Un moyen est d'augmenter l'option [checkTimeoutInterval](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/docs/API.md#mccreateclientoptions) (à définir dans createBot) à une valeur plus élevée (par exemple `300*1000` qui est 5min au lieu des 30s par défaut). Si vous êtes toujours déconnecté, vous pouvez vous reconnecter automatiquement en utilisant quelque chose comme cet exemple <https://github.com/PrismarineJS/mineflayer/blob/master/examples/reconnector.js>
93
+
94
+ ### Comment obtenir l'histoire / le texte d'un objet ?
95
+
96
+ Vous pouvez utiliser la propriété `item.nbt`. Il est également recommandé d'utiliser la bibliothèque `prismarine-nbt`. La méthode `nbt.simplify()` peut être utile.
97
+
98
+ **Exemple:**
99
+
100
+ ```js
101
+ function getLore (item) {
102
+ let message = ''
103
+ if (item.nbt == null) return message
104
+
105
+ const nbt = require('prismarine-nbt')
106
+ const ChatMessage = require('prismarine-chat')(bot.version)
107
+
108
+ const data = nbt.simplify(item.nbt)
109
+ const display = data.display
110
+ if (display == null) return message
111
+
112
+ const lore = display.Lore
113
+ if (lore == null) return message
114
+ for (const line of lore) {
115
+ message += new ChatMessage(line).toString()
116
+ message += '\n'
117
+ }
118
+
119
+ return message
120
+ }
121
+ ```
122
+
123
+ ### Comment puis-je envoyer un message de la console au serveur ?
124
+
125
+ You can use a library like `repl` to read the console input and use `bot.chat()` to send it. You can find an example [here.](https://github.com/PrismarineJS/mineflayer/blob/master/examples/repl.js)
126
+
127
+ ### Lors de la création d'un plugin, comment puis-je spécifier un autre plugin comme dépendance ?
128
+
129
+ Dans la fonction `inject()` de votre plugin, vous pouvez appeler sans risque `bot.loadPlugin(anotherPlugin)` pour vous assurer que ce plugin est chargé. Si le plugin a déjà été chargé auparavant, rien ne se passe.
130
+
131
+ Notez que l'ordre dans lequel les plugins sont chargés est dynamique, donc vous ne devriez jamais appeler un autre plugin dans votre fonction `inject()`.
132
+
133
+ ### Comment puis-je utiliser un proxy socks5 ?
134
+
135
+ In the options object for `mineflayer.createBot(options)`, remove your `host` option from the options object, have the following variables declared `PROXY_IP, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD, MC_SERVER_ADDRESS, MC_SERVER_PORT` and add this to your options object:
136
+
137
+ ```js
138
+ connect: (client) => {
139
+ socks.createConnection({
140
+ proxy: {
141
+ host: PROXY_IP,
142
+ port: PROXY_PORT,
143
+ type: 5,
144
+ userId: PROXY_USERNAME,
145
+ password: PROXY_PASSWORD
146
+ },
147
+ command: 'connect',
148
+ destination: {
149
+ host: MC_SERVER_ADDRESS,
150
+ port: MC_SERVER_PORT
151
+ }
152
+ }, (err, info) => {
153
+ if (err) {
154
+ console.log(err)
155
+ return
156
+ }
157
+ client.setSocket(info.socket)
158
+ client.emit('connect')
159
+ })
160
+ }
161
+ ```
162
+
163
+ `socks` est déclaré avec `const socks = require('socks').SocksClient` et utilise le paquet [this](https://www.npmjs.com/package/socks).
164
+ Certains serveurs peuvent rejeter la connexion. Si cela se produit, essayez d'ajouter `fakeHost : MC_SERVER_ADDRESS` aux options de votre createBot.
165
+
166
+ # Erreurs courantes
167
+
168
+ ### `UnhandledPromiseRejectionWarning: Error: Failed to read asymmetric key`
169
+
170
+ Voici ce qui se passe lorsque vous avez donné à Mineflayer la mauvaise version du serveur, ou que Mineflayer détecte la mauvaise version du serveur.
171
+
172
+ ### `TypeError: Cannot read property '?' of undefined`
173
+
174
+ Vous essayez peut-être d'utiliser quelque chose sur l'objet bot qui n'existe pas encore, essayez d'appeler l'instruction après l'événement `spawn`.
175
+
176
+ ### `SyntaxError: Unexpected token '?'`
177
+
178
+ Mettez à jour la version de votre node.
179
+
180
+ ### The bot can't break/place blocks or open chests
181
+
182
+ Vérifiez que la protection contre le spawn n'empêche pas le bot d'agir.
package/docs/history.md CHANGED
@@ -1,3 +1,14 @@
1
+ 4.6.0
2
+
3
+ * Fix unhandled promise rejection in onceWithCleanup (@IceTank) [#2833](https://github.com/PrismarineJS/mineflayer/pull/2833)
4
+ * Extend every window that is opened with mineflayer specific window functions (@IceTank) [#2768][https://github.com/PrismarineJS/mineflayer/pull/2768]
5
+ * Fix example command line usage messages (@maximmasiutin) [#2853](https://github.com/PrismarineJS/mineflayer/pull/2853)
6
+ * Update README_ES.md (@PanIntegralus) [#2803](https://github.com/PrismarineJS/mineflayer/pull/2803)
7
+ * Fix block face position target when digging (@WhoTho) [#2801](https://github.com/PrismarineJS/mineflayer/pull/2801)
8
+ * Add a native mineflayer event for particles (@NyxaYu) [#2813](https://github.com/PrismarineJS/mineflayer/pull/2813)
9
+ * Fix viewDistance type (@Nciklol) [#2824](Fix viewDistance type (#2824) )
10
+ * Add French FAQ (@AugustinMauroy) [#2817](https://github.com/PrismarineJS/mineflayer/pull/2817)
11
+
1
12
  ## 4.5.1
2
13
 
3
14
  * Fixed syntax error in TypeScript definitions (@JungleDome) [commit](https://github.com/PrismarineJS/mineflayer/commit/2c6a4036d84bedb5f349ea5a82d743e344c34224)
package/examples/anvil.js CHANGED
@@ -18,7 +18,7 @@
18
18
  const mineflayer = require('mineflayer')
19
19
 
20
20
  if (process.argv.length < 4 || process.argv.length > 6) {
21
- console.log('Usage : node use_anvil.js <host> <port> [<name>] [<password>]')
21
+ console.log('Usage : node anvil.js <host> <port> [<name>] [<password>]')
22
22
  process.exit(1)
23
23
  }
24
24
 
@@ -6,12 +6,7 @@ const pathfinder = require('mineflayer-pathfinder').pathfinder
6
6
  const collectBlock = require('mineflayer-collectblock').plugin
7
7
 
8
8
  if (process.argv.length < 4 || process.argv.length > 6) {
9
- console.log('Usage : node collector.js <host> <port> [<name>] [<password>]')
10
- process.exit(1)
11
- }
12
-
13
- if (process.argv.length < 4 || process.argv.length > 6) {
14
- console.log('Usage : node collectBlock.js <host> <port> [<name>] [<password>]')
9
+ console.log('Usage : node collectblock.js <host> <port> [<name>] [<password>]')
15
10
  process.exit(1)
16
11
  }
17
12
 
@@ -5,7 +5,7 @@
5
5
  const mineflayer = require('mineflayer')
6
6
 
7
7
  if (process.argv.length < 4 || process.argv.length > 6) {
8
- console.log('Usage : node echo.js <host> <port> [<name>] [<password>]')
8
+ console.log('Usage : node looker.js <host> <port> [<name>] [<password>]')
9
9
  process.exit(1)
10
10
  }
11
11
 
@@ -7,7 +7,7 @@
7
7
  const mineflayer = require('mineflayer')
8
8
 
9
9
  if (process.argv.length < 4 || process.argv.length > 6) {
10
- console.log('Usage : node jumper.js <host> <port> [<name>] [<password>]')
10
+ console.log('Usage : node skin_blinker.js <host> <port> [<name>] [<password>]')
11
11
  process.exit(1)
12
12
  }
13
13
 
package/index.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface BotOptions extends ClientOptions {
30
30
  }
31
31
 
32
32
  export type ChatLevel = 'enabled' | 'commandsOnly' | 'disabled'
33
- export type ViewDistance = 'far' | 'normal' | 'short' | 'tiny'
33
+ export type ViewDistance = 'far' | 'normal' | 'short' | 'tiny' | number
34
34
  export type MainHands = 'left' | 'right'
35
35
 
36
36
  export interface PluginOptions {
@@ -151,6 +151,7 @@ interface BotEvents {
151
151
  bossBarDeleted: (bossBar: BossBar) => Promise<void> | void
152
152
  bossBarUpdated: (bossBar: BossBar) => Promise<void> | void
153
153
  resourcePack: (url: string, hash: string) => Promise<void> | void
154
+ particle: (particle: Particle) => Promise<void> | void
154
155
  }
155
156
 
156
157
  export interface Bot extends TypedEmitter<BotEvents> {
@@ -826,6 +827,26 @@ export class BossBar {
826
827
  );
827
828
  }
828
829
 
830
+ export class Particle {
831
+ id: number
832
+ name: string
833
+ position: Vec3
834
+ offset: Vec3
835
+ count: number
836
+ movementSpeed: number
837
+ longDistanceRender: boolean
838
+ static fromNetwork(packet: Object): Particle
839
+
840
+ constructor (
841
+ id: number,
842
+ position: Vec3,
843
+ offset: Vec3,
844
+ count?: number,
845
+ movementSpeed?: number,
846
+ longDistanceRender?: boolean
847
+ );
848
+ }
849
+
829
850
  export let supportedVersions: string[]
830
851
  export let testedVersions: string[]
831
852
 
package/lib/loader.js CHANGED
@@ -41,7 +41,8 @@ const plugins = {
41
41
  villager: require('./plugins/villager'),
42
42
  anvil: require('./plugins/anvil'),
43
43
  place_entity: require('./plugins/place_entity'),
44
- generic_place: require('./plugins/generic_place')
44
+ generic_place: require('./plugins/generic_place'),
45
+ particle: require('./plugins/particle')
45
46
  }
46
47
 
47
48
  const supportedVersions = require('./version').supportedVersions
@@ -53,6 +54,7 @@ module.exports = {
53
54
  Painting: require('./painting'),
54
55
  ScoreBoard: require('./scoreboard'),
55
56
  BossBar: require('./bossbar'),
57
+ Particle: require('./particle'),
56
58
  supportedVersions,
57
59
  testedVersions,
58
60
  supportFeature: (feature, version) => require('prismarine-registry')(version).supportFeature(feature)
@@ -0,0 +1,30 @@
1
+ const { Vec3 } = require('vec3')
2
+
3
+ module.exports = loader
4
+
5
+ function loader (registry) {
6
+ class Particle {
7
+ constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false) {
8
+ Object.assign(this, registry.particles[id])
9
+ this.id = id
10
+ this.position = position
11
+ this.offset = offset
12
+ this.count = count
13
+ this.movementSpeed = movementSpeed
14
+ this.longDistanceRender = longDistanceRender
15
+ }
16
+
17
+ static fromNetwork (packet) {
18
+ return new Particle(
19
+ packet.particleId,
20
+ new Vec3(packet.x, packet.y, packet.z),
21
+ new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
22
+ packet.particles,
23
+ packet.particleData,
24
+ packet.longDistance
25
+ )
26
+ }
27
+ }
28
+
29
+ return Particle
30
+ }
@@ -36,15 +36,17 @@ function inject (bot) {
36
36
  } else if (digFace.z) {
37
37
  diggingFace = digFace.z > 0 ? BlockFaces.SOUTH : BlockFaces.NORTH
38
38
  }
39
- await bot.lookAt(block.position.offset(0.5, 0.5, 0.5).offset(digFace.x * 0.5, digFace.y * 0.5, digFace.z * 0.5), forceLook)
39
+ await bot.lookAt(
40
+ block.position.offset(0.5, 0.5, 0.5).offset(digFace.x * 0.5, digFace.y * 0.5, digFace.z * 0.5),
41
+ forceLook
42
+ )
40
43
  } else if (digFace === 'raycast') {
41
44
  // Check faces that could be seen from the current position. If the delta is smaller then 0.5 that means the
42
45
  // bot cam most likely not see the face as the block is 1 block thick
43
46
  // this could be false for blocks that have a smaller bounding box then 1x1x1
44
- const dx = bot.entity.position.x - block.position.x + 0.5
45
- const dy = bot.entity.position.y - block.position.y - 0.5 + bot.entity.height // -0.5 because the bot position
46
- // is calculated from the block position that is inside its feet so 0.5 - 1 = -0.5
47
- const dz = bot.entity.position.z - block.position.z + 0.5
47
+ const dx = bot.entity.position.x - (block.position.x + 0.5)
48
+ const dy = bot.entity.position.y + bot.entity.height - (block.position.y + 0.5)
49
+ const dz = bot.entity.position.z - (block.position.z + 0.5)
48
50
  // Check y first then x and z
49
51
  const visibleFaces = {
50
52
  y: Math.sign(Math.abs(dy) > 0.5 ? dy : 0),
@@ -55,12 +57,20 @@ function inject (bot) {
55
57
  for (const i in visibleFaces) {
56
58
  if (!visibleFaces[i]) continue // skip as this face is not visible
57
59
  // target position on the target block face. -> 0.5 + (current face) * 0.5
58
- const targetPos = block.position.offset(0.5 + (i === 'x' ? visibleFaces[i] * 0.5 : 0), 0.5 + (i === 'y' ? visibleFaces[i] * 0.5 : 0), 0.5 + (i === 'z' ? visibleFaces[i] * 0.5 : 0))
60
+ const targetPos = block.position.offset(
61
+ 0.5 + (i === 'x' ? visibleFaces[i] * 0.5 : 0),
62
+ 0.5 + (i === 'y' ? visibleFaces[i] * 0.5 : 0),
63
+ 0.5 + (i === 'z' ? visibleFaces[i] * 0.5 : 0)
64
+ )
59
65
  const startPos = bot.entity.position.offset(0, bot.entity.height, 0)
60
66
  const rayBlock = bot.world.raycast(startPos, targetPos.clone().subtract(startPos).normalize(), 5)
61
67
  if (rayBlock) {
62
68
  const rayPos = rayBlock.position
63
- if (rayPos.x === block.position.x && rayPos.y === block.position.y && rayPos.z === block.position.z) {
69
+ if (
70
+ rayPos.x === block.position.x &&
71
+ rayPos.y === block.position.y &&
72
+ rayPos.z === block.position.z
73
+ ) {
64
74
  // console.info(rayBlock)
65
75
  validFaces.push({
66
76
  face: rayBlock.face,
@@ -75,7 +85,9 @@ function inject (bot) {
75
85
  let distSqrt = 999
76
86
  for (const i in validFaces) {
77
87
  const tPos = validFaces[i].targetPos
78
- const cDist = new Vec3(tPos.x, tPos.y, tPos.z).distanceSquared(bot.entity.position.offset(0, bot.entity.height, 0))
88
+ const cDist = new Vec3(tPos.x, tPos.y, tPos.z).distanceSquared(
89
+ bot.entity.position.offset(0, bot.entity.height, 0)
90
+ )
79
91
  if (distSqrt > cDist) {
80
92
  closest = validFaces[i]
81
93
  distSqrt = cDist
@@ -172,7 +184,11 @@ function inject (bot) {
172
184
  })
173
185
 
174
186
  function canDigBlock (block) {
175
- return block && block.diggable && block.position.offset(0.5, 0.5, 0.5).distanceTo(bot.entity.position.offset(0, 1.65, 0)) <= 5.1
187
+ return (
188
+ block &&
189
+ block.diggable &&
190
+ block.position.offset(0.5, 0.5, 0.5).distanceTo(bot.entity.position.offset(0, 1.65, 0)) <= 5.1
191
+ )
176
192
  }
177
193
 
178
194
  function digTime (block) {
@@ -195,7 +211,14 @@ function inject (bot) {
195
211
  }
196
212
 
197
213
  const creative = bot.game.gameMode === 'creative'
198
- return block.digTime(type, creative, bot.entity.isInWater, !bot.entity.onGround, enchantments, bot.entity.effects)
214
+ return block.digTime(
215
+ type,
216
+ creative,
217
+ bot.entity.isInWater,
218
+ !bot.entity.onGround,
219
+ enchantments,
220
+ bot.entity.effects
221
+ )
199
222
  }
200
223
 
201
224
  bot.dig = dig
@@ -588,6 +588,7 @@ function inject (bot, { hideErrors }) {
588
588
  if (!windowItems || window.id !== windowItems.windowId) {
589
589
  // don't emit windowOpen until we have the slot data
590
590
  bot.once(`setWindowItems:${window.id}`, () => {
591
+ extendWindow(window)
591
592
  bot.emit('windowOpen', window)
592
593
  })
593
594
  } else {
@@ -596,6 +597,7 @@ function inject (bot, { hideErrors }) {
596
597
  window.updateSlot(i, item)
597
598
  }
598
599
  updateHeldItem()
600
+ extendWindow(window)
599
601
  bot.emit('windowOpen', window)
600
602
  }
601
603
  }
@@ -0,0 +1,9 @@
1
+ module.exports = inject
2
+
3
+ function inject (bot, { version }) {
4
+ const Particle = require('../particle')(bot.registry)
5
+
6
+ bot._client.on('world_particles', (packet) => {
7
+ bot.emit('particle', Particle.fromNetwork(packet))
8
+ })
9
+ }
@@ -67,7 +67,7 @@ function onceWithCleanup (emitter, event, { timeout = 0, checkCondition = undefi
67
67
  })
68
68
  }
69
69
 
70
- task.promise.finally(() => emitter.removeListener(event, onEvent))
70
+ task.promise.catch(() => {}).finally(() => emitter.removeListener(event, onEvent))
71
71
 
72
72
  return task.promise
73
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mineflayer",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "description": "create minecraft bots with a stable, high level API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",