mineflayer 3.15.0 → 4.0.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/lib/features.json CHANGED
@@ -328,5 +328,10 @@
328
328
  "name": "tallWorld",
329
329
  "description": "world starts at -64 and ends at 384",
330
330
  "versions": ["1.18", "1.18.1"]
331
+ },
332
+ {
333
+ "name": "sendStringifiedSignText",
334
+ "description": "sign text send when updating signs is send as stringified strings",
335
+ "versions": ["1.8", "1.8.9"]
331
336
  }
332
337
  ]
@@ -1,5 +1,5 @@
1
1
  const assert = require('assert')
2
- const { callbackify, sleep } = require('../promise_utils')
2
+ const { sleep } = require('../promise_utils')
3
3
  const { once } = require('events')
4
4
 
5
5
  module.exports = inject
@@ -105,11 +105,11 @@ function inject (bot) {
105
105
  await bot.transfer(options)
106
106
  }
107
107
 
108
- anvil.combine = callbackify(combine)
109
- anvil.rename = callbackify(rename)
108
+ anvil.combine = combine
109
+ anvil.rename = rename
110
110
 
111
111
  return anvil
112
112
  }
113
113
 
114
- bot.openAnvil = callbackify(openAnvil)
114
+ bot.openAnvil = openAnvil
115
115
  }
@@ -1,5 +1,4 @@
1
1
  const { Vec3 } = require('vec3')
2
- const { callbackify } = require('../promise_utils')
3
2
 
4
3
  module.exports = inject
5
4
 
@@ -174,7 +173,7 @@ function inject (bot) {
174
173
  })
175
174
 
176
175
  bot.parseBedMetadata = parseBedMetadata
177
- bot.wake = callbackify(wake)
178
- bot.sleep = callbackify(sleep)
176
+ bot.wake = wake
177
+ bot.sleep = sleep
179
178
  bot.isABed = isABed
180
179
  }
@@ -1,7 +1,7 @@
1
1
  const { Vec3 } = require('vec3')
2
2
  const assert = require('assert')
3
3
  const Painting = require('../painting')
4
- const { onceWithCleanup, callbackify } = require('../promise_utils')
4
+ const { onceWithCleanup } = require('../promise_utils')
5
5
 
6
6
  const { OctahedronIterator } = require('prismarine-world').iterators
7
7
 
@@ -21,17 +21,12 @@ const dimensionNames = {
21
21
  }
22
22
 
23
23
  function inject (bot, { version, storageBuilder }) {
24
- const nbt = require('prismarine-nbt')
25
24
  const Block = require('prismarine-block')(version)
26
25
  const Chunk = require('prismarine-chunk')(version)
27
- const ChatMessage = require('prismarine-chat')(version)
28
26
  const World = require('prismarine-world')(version)
29
- const signs = {}
30
27
  const paintingsByPos = {}
31
28
  const paintingsById = {}
32
29
 
33
- const blockEntities = new Map()
34
-
35
30
  function addPainting (painting) {
36
31
  paintingsById[painting.id] = painting
37
32
  paintingsByPos[painting.position] = painting
@@ -42,43 +37,6 @@ function inject (bot, { version, storageBuilder }) {
42
37
  delete paintingsByPos[painting.position]
43
38
  }
44
39
 
45
- function addBlockEntity (nbtData, x, y, z, type) {
46
- const blockEntity = nbtData === undefined ? {} : nbt.simplify(nbtData)
47
- const pos = (x !== undefined ? new Vec3(x, y, z) : new Vec3(blockEntity.x, blockEntity.y, blockEntity.z)).floored()
48
- // Set raw nbt of blockEntity
49
- blockEntity.raw = nbtData
50
- blockEntity.type = type
51
- const signType = 7
52
- // Handle signs
53
- if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign' || blockEntity.type === signType) {
54
- const prepareJson = (i) => {
55
- const data = blockEntity[`Text${i}`]
56
-
57
- if (data === null || data === '') return ''
58
-
59
- const json = JSON.parse(data)
60
- if (json === null || !('text' in json)) return ''
61
-
62
- json.text = json.text.replace(/^"|"$/g, '')
63
- return json
64
- }
65
-
66
- blockEntity.Text1 = new ChatMessage(prepareJson(1))
67
- blockEntity.Text2 = new ChatMessage(prepareJson(2))
68
- blockEntity.Text3 = new ChatMessage(prepareJson(3))
69
- blockEntity.Text4 = new ChatMessage(prepareJson(4))
70
-
71
- signs[pos] = [
72
- blockEntity.Text1.toString(),
73
- blockEntity.Text2.toString(),
74
- blockEntity.Text3.toString(),
75
- blockEntity.Text4.toString()
76
- ].join('\n')
77
- }
78
-
79
- blockEntities[pos] = blockEntity
80
- }
81
-
82
40
  function delColumn (chunkX, chunkZ) {
83
41
  bot.world.unloadColumn(chunkX, chunkZ)
84
42
  }
@@ -254,9 +212,7 @@ function inject (bot, { version, storageBuilder }) {
254
212
  if (!block) return null
255
213
 
256
214
  if (extraInfos) {
257
- block.signText = signs[block.position]
258
215
  block.painting = paintingsByPos[block.position]
259
- block.blockEntity = blockEntities[block.position]
260
216
  }
261
217
 
262
218
  return block
@@ -293,9 +249,6 @@ function inject (bot, { version, storageBuilder }) {
293
249
  }
294
250
  if (oldBlock.type !== newBlock.type) {
295
251
  const pos = point.floored()
296
- delete blockEntities[pos]
297
- delete signs[pos]
298
-
299
252
  const painting = paintingsByPos[pos]
300
253
  if (painting) deletePainting(painting)
301
254
  }
@@ -335,11 +288,13 @@ function inject (bot, { version, storageBuilder }) {
335
288
  })
336
289
 
337
290
  if (typeof packet.blockEntities !== 'undefined') {
291
+ const column = bot.world.getColumn(packet.x, packet.z)
338
292
  for (const blockEntity of packet.blockEntities) {
339
- if (blockEntity.x !== undefined) {
340
- addBlockEntity(blockEntity.nbtData, blockEntity.x, blockEntity.y, blockEntity.z, blockEntity.type)
293
+ if (blockEntity.x !== undefined) { // 1.17+
294
+ column.setBlockEntity(blockEntity, blockEntity.nbtData)
341
295
  } else {
342
- addBlockEntity(blockEntity)
296
+ const pos = new Vec3(blockEntity.value.x.value & 0xf, blockEntity.value.y.value, blockEntity.value.z.value & 0xf)
297
+ column.setBlockEntity(pos, blockEntity)
343
298
  }
344
299
  }
345
300
  }
@@ -434,36 +389,33 @@ function inject (bot, { version, storageBuilder }) {
434
389
  })
435
390
 
436
391
  bot._client.on('update_sign', (packet) => {
437
- const pos = new Vec3(packet.location.x, packet.location.y, packet.location.z)
438
-
439
- const prepareString = (i) => {
440
- let text = packet[`text${i}`]
392
+ const pos = new Vec3(packet.location.x & 0xf, packet.location.y, packet.location.z & 0xf)
441
393
 
442
- if (text === 'null' || text === '') {
443
- text = '""'
444
- }
445
-
446
- const json = JSON.parse(text)
447
- if (json.text) {
448
- json.text = json.text.replace(/^"|"$/g, '')
449
- }
450
-
451
- return new ChatMessage(json)
394
+ // TODO: warn if out of loaded world?
395
+ const column = bot.world.getColumn(packet.location.x >> 4, packet.location.z >> 4)
396
+ if (!column) {
397
+ return
452
398
  }
453
399
 
454
- signs[pos] = [
455
- prepareString(1),
456
- prepareString(2),
457
- prepareString(3),
458
- prepareString(4)
459
- ].join('\n')
400
+ const blockAt = column.getBlock(pos)
401
+
402
+ blockAt.signText = [packet.text1, packet.text2, packet.text3, packet.text4].map(text => {
403
+ if (text === 'null' || text === '') return ''
404
+ return JSON.parse(text)
405
+ })
406
+ column.setBlock(pos, blockAt)
460
407
  })
461
408
 
462
409
  bot._client.on('tile_entity_data', (packet) => {
463
410
  if (packet.location !== undefined) {
464
- addBlockEntity(packet.nbtData, packet.location.x, packet.location.y, packet.location.z, packet.action)
411
+ const column = bot.world.getColumn(packet.location.x >> 4, packet.location.z >> 4)
412
+ const pos = new Vec3(packet.location.x & 0xf, packet.location.y, packet.location.z & 0xf)
413
+ column.setBlockEntity(pos, packet.nbtData)
465
414
  } else {
466
- addBlockEntity(packet.nbtData)
415
+ const tag = packet.nbtData
416
+ const column = bot.world.getColumn(tag.value.x.value >> 4, tag.value.z.value >> 4)
417
+ const pos = new Vec3(tag.value.x.value & 0xf, tag.value.y.value, tag.value.z.value & 0xf)
418
+ column.setBlockEntity(pos, tag)
467
419
  }
468
420
  })
469
421
 
@@ -480,12 +432,25 @@ function inject (bot, { version, storageBuilder }) {
480
432
  }
481
433
  }
482
434
 
435
+ let signData
436
+ if (bot.supportFeature('sendStringifiedSignText')) {
437
+ signData = {
438
+ text1: lines[0] ? JSON.stringify(lines[0]) : '""',
439
+ text2: lines[1] ? JSON.stringify(lines[1]) : '""',
440
+ text3: lines[2] ? JSON.stringify(lines[2]) : '""',
441
+ text4: lines[3] ? JSON.stringify(lines[3]) : '""'
442
+ }
443
+ } else {
444
+ signData = {
445
+ text1: lines[0] ?? '',
446
+ text2: lines[1] ?? '',
447
+ text3: lines[2] ?? '',
448
+ text4: lines[3] ?? ''
449
+ }
450
+ }
483
451
  bot._client.write('update_sign', {
484
452
  location: block.position,
485
- text1: JSON.stringify(lines[0]),
486
- text2: JSON.stringify(lines[1]),
487
- text3: JSON.stringify(lines[2]),
488
- text4: JSON.stringify(lines[3])
453
+ ...signData
489
454
  })
490
455
  }
491
456
 
@@ -583,8 +548,7 @@ function inject (bot, { version, storageBuilder }) {
583
548
  bot.canSeeBlock = canSeeBlock
584
549
  bot.blockAt = blockAt
585
550
  bot._updateBlockState = updateBlockState
586
- bot._blockEntities = blockEntities
587
- bot.waitForChunksToLoad = callbackify(waitForChunksToLoad)
551
+ bot.waitForChunksToLoad = waitForChunksToLoad
588
552
  }
589
553
 
590
554
  function onesInShort (n) {
@@ -1,6 +1,5 @@
1
1
  const assert = require('assert')
2
2
  const { once } = require('events')
3
- const { callbackify } = require('../promise_utils')
4
3
 
5
4
  module.exports = inject
6
5
 
@@ -83,11 +82,11 @@ function inject (bot, { version }) {
83
82
  return book
84
83
  }
85
84
 
86
- bot.writeBook = callbackify(async (slot, pages) => {
85
+ bot.writeBook = async (slot, pages) => {
87
86
  await write(slot, pages, null, null, false)
88
- })
87
+ }
89
88
 
90
- bot.signBook = callbackify(async (slot, pages, author, title) => {
89
+ bot.signBook = async (slot, pages, author, title) => {
91
90
  await write(slot, pages, author, title, true)
92
- })
91
+ }
93
92
  }
@@ -169,7 +169,7 @@ function inject (bot, options) {
169
169
  chatWithHeader('', message)
170
170
  }
171
171
 
172
- bot.tabComplete = callbackify(tabComplete)
172
+ bot.tabComplete = tabComplete
173
173
 
174
174
  function addDefaultPatterns () {
175
175
  if (!defaultChatPatterns) return
@@ -193,11 +193,3 @@ function inject (bot, options) {
193
193
  }
194
194
  bot.awaitMessage = awaitMessage
195
195
  }
196
-
197
- function callbackify (f) { // specifically for this function because cb isn't the last parameter
198
- return function (...args) {
199
- const cb = args[1]
200
- args.splice(1, 1)
201
- return f(...args).then(r => { if (cb) { cb(undefined, r) } return r }, err => { if (cb) { cb(err) } else throw err })
202
- }
203
- }
@@ -1,4 +1,3 @@
1
- const { callbackify } = require('../promise_utils')
2
1
 
3
2
  module.exports = inject
4
3
 
@@ -26,7 +25,7 @@ function inject (bot) {
26
25
  return chest
27
26
  }
28
27
 
29
- bot.openContainer = callbackify(openContainer)
30
- bot.openChest = callbackify(openContainer)
31
- bot.openDispenser = callbackify(openContainer)
28
+ bot.openContainer = openContainer
29
+ bot.openChest = openContainer
30
+ bot.openDispenser = openContainer
32
31
  }
@@ -1,6 +1,5 @@
1
1
  const assert = require('assert')
2
2
  const { once } = require('events')
3
- const { callbackify } = require('../promise_utils')
4
3
 
5
4
  module.exports = inject
6
5
 
@@ -226,7 +225,7 @@ function inject (bot, { version }) {
226
225
  return true
227
226
  }
228
227
 
229
- bot.craft = callbackify(craft)
228
+ bot.craft = craft
230
229
  bot.recipesFor = recipesFor
231
230
  bot.recipesAll = recipesAll
232
231
  }
@@ -1,6 +1,6 @@
1
1
  const assert = require('assert')
2
2
  const { Vec3 } = require('vec3')
3
- const { callbackify, sleep } = require('../promise_utils')
3
+ const { sleep } = require('../promise_utils')
4
4
  const { once } = require('events')
5
5
 
6
6
  module.exports = inject
@@ -10,8 +10,8 @@ function inject (bot, { version }) {
10
10
 
11
11
  // these features only work when you are in creative mode.
12
12
  bot.creative = {
13
- setInventorySlot: callbackify(setInventorySlot),
14
- flyTo: callbackify(flyTo),
13
+ setInventorySlot: setInventorySlot,
14
+ flyTo: flyTo,
15
15
  startFlying,
16
16
  stopFlying
17
17
  }
@@ -23,7 +23,7 @@ function inject (bot, { version }) {
23
23
  }
24
24
  })
25
25
 
26
- // WARN: This method should not be called twice on the same slot before first callback succeeds
26
+ // WARN: This method should not be called twice on the same slot before first promise succeeds
27
27
  async function setInventorySlot (slot, item) {
28
28
  assert(slot >= 0 && slot <= 44)
29
29
 
@@ -198,25 +198,12 @@ function inject (bot) {
198
198
  return block.digTime(type, creative, bot.entity.isInWater, !bot.entity.onGround, enchantments, bot.entity.effects)
199
199
  }
200
200
 
201
- bot.dig = callbackify(dig)
201
+ bot.dig = dig
202
202
  bot.stopDigging = noop
203
203
  bot.canDigBlock = canDigBlock
204
204
  bot.digTime = digTime
205
205
  }
206
206
 
207
- function callbackify (f) { // specifically for this function because cb could be the non-last parameter
208
- return function (...args) {
209
- const cbIndex = typeof args[1] === 'function' ? 1 : (typeof args[2] === 'function' ? 2 : 3)
210
- const cb = args[cbIndex]
211
-
212
- if (cbIndex === 1) args[1] = true
213
- else if (typeof args[1] === 'string') args[1] = args[1] === 'ignore' ? args[1] : false
214
- else args[1] = !!args[1] // coerce to boolean
215
-
216
- return f(...args).then(r => { if (cb) { cb(undefined, r) } return r }, err => { if (cb) { cb(err) } else throw err })
217
- }
218
- }
219
-
220
207
  function noop (err) {
221
208
  if (err) throw err
222
209
  }
@@ -1,6 +1,5 @@
1
1
  const assert = require('assert')
2
2
  const { once } = require('events')
3
- const { callbackify } = require('../promise_utils')
4
3
 
5
4
  module.exports = inject
6
5
 
@@ -15,10 +14,10 @@ function inject (bot) {
15
14
 
16
15
  resetEnchantmentOptions()
17
16
 
18
- enchantmentTable.enchant = callbackify(enchant)
19
- enchantmentTable.takeTargetItem = callbackify(takeTargetItem)
20
- enchantmentTable.putTargetItem = callbackify(putTargetItem)
21
- enchantmentTable.putLapis = callbackify(putLapis)
17
+ enchantmentTable.enchant = enchant
18
+ enchantmentTable.takeTargetItem = takeTargetItem
19
+ enchantmentTable.putTargetItem = putTargetItem
20
+ enchantmentTable.putLapis = putLapis
22
21
  enchantmentTable.targetItem = function () { return this.slots[0] }
23
22
 
24
23
  bot._client.on('craft_progress_bar', onUpdateWindowProperty)
@@ -100,5 +99,5 @@ function inject (bot) {
100
99
  }
101
100
  }
102
101
 
103
- bot.openEnchantmentTable = callbackify(openEnchantmentTable)
102
+ bot.openEnchantmentTable = openEnchantmentTable
104
103
  }
@@ -588,6 +588,7 @@ function inject (bot, { version }) {
588
588
  }
589
589
 
590
590
  function useEntity (target, leftClick, x, y, z) {
591
+ const sneaking = bot.getControlState('sneak')
591
592
  if (x && y && z) {
592
593
  bot._client.write('use_entity', {
593
594
  target: target.id,
@@ -595,13 +596,13 @@ function inject (bot, { version }) {
595
596
  x,
596
597
  y,
597
598
  z,
598
- sneaking: false
599
+ sneaking
599
600
  })
600
601
  } else {
601
602
  bot._client.write('use_entity', {
602
603
  target: target.id,
603
604
  mouse: leftClick,
604
- sneaking: false
605
+ sneaking
605
606
  })
606
607
  }
607
608
  }
@@ -1,5 +1,5 @@
1
1
  const { Vec3 } = require('vec3')
2
- const { callbackify, createDoneTask, createTask } = require('../promise_utils')
2
+ const { createDoneTask, createTask } = require('../promise_utils')
3
3
 
4
4
  module.exports = inject
5
5
 
@@ -54,5 +54,5 @@ function inject (bot) {
54
54
  await fishingTask.promise
55
55
  }
56
56
 
57
- bot.fish = callbackify(fish)
57
+ bot.fish = fish
58
58
  }
@@ -1,5 +1,4 @@
1
1
  const assert = require('assert')
2
- const { callbackify } = require('../promise_utils')
3
2
 
4
3
  module.exports = inject
5
4
 
@@ -25,11 +24,11 @@ function inject (bot) {
25
24
  furnace.totalProgress = null
26
25
  furnace.progress = null
27
26
  furnace.progressSeconds = null
28
- furnace.takeInput = callbackify(takeInput)
29
- furnace.takeFuel = callbackify(takeFuel)
30
- furnace.takeOutput = callbackify(takeOutput)
31
- furnace.putInput = callbackify(putInput)
32
- furnace.putFuel = callbackify(putFuel)
27
+ furnace.takeInput = takeInput
28
+ furnace.takeFuel = takeFuel
29
+ furnace.takeOutput = takeOutput
30
+ furnace.putInput = putInput
31
+ furnace.putFuel = putFuel
33
32
  furnace.inputItem = function () { return this.slots[0] }
34
33
  furnace.fuelItem = function () { return this.slots[1] }
35
34
  furnace.outputItem = function () { return this.slots[2] }
@@ -118,5 +117,5 @@ function inject (bot) {
118
117
  return ticks * 0.05
119
118
  }
120
119
 
121
- bot.openFurnace = callbackify(openFurnace)
120
+ bot.openFurnace = openFurnace
122
121
  }
@@ -1,7 +1,7 @@
1
1
  const assert = require('assert')
2
2
  const { Vec3 } = require('vec3')
3
3
  const { once } = require('events')
4
- const { callbackify, sleep, createDoneTask, createTask, withTimeout } = require('../promise_utils')
4
+ const { sleep, createDoneTask, createTask, withTimeout } = require('../promise_utils')
5
5
 
6
6
  module.exports = inject
7
7
 
@@ -306,7 +306,7 @@ function inject (bot, { version, hideErrors }) {
306
306
  window.emit('close')
307
307
  closeWindow(window)
308
308
  }
309
- window.withdraw = callbackify(async (itemType, metadata, count) => {
309
+ window.withdraw = async (itemType, metadata, count) => {
310
310
  if (bot.inventory.emptySlotCount() === 0) {
311
311
  throw new Error('Unable to withdraw, Bot inventory is full.')
312
312
  }
@@ -322,8 +322,8 @@ function inject (bot, { version, hideErrors }) {
322
322
  destEnd: window.inventoryEnd
323
323
  }
324
324
  await transfer(options)
325
- })
326
- window.deposit = callbackify(async (itemType, metadata, count) => {
325
+ }
326
+ window.deposit = async (itemType, metadata, count) => {
327
327
  const options = {
328
328
  window: window,
329
329
  itemType,
@@ -335,7 +335,7 @@ function inject (bot, { version, hideErrors }) {
335
335
  destEnd: window.inventoryStart
336
336
  }
337
337
  await transfer(options)
338
- })
338
+ }
339
339
  }
340
340
 
341
341
  async function openBlock (block) {
@@ -643,21 +643,21 @@ function inject (bot, { version, hideErrors }) {
643
643
  bot.emit(`setWindowItems:${window.id}`)
644
644
  })
645
645
 
646
- bot.activateBlock = callbackify(activateBlock)
647
- bot.activateEntity = callbackify(activateEntity)
648
- bot.activateEntityAt = callbackify(activateEntityAt)
649
- bot.consume = callbackify(consume)
646
+ bot.activateBlock = activateBlock
647
+ bot.activateEntity = activateEntity
648
+ bot.activateEntityAt = activateEntityAt
649
+ bot.consume = consume
650
650
  bot.activateItem = activateItem
651
651
  bot.deactivateItem = deactivateItem
652
652
 
653
653
  // not really in the public API
654
- bot.clickWindow = callbackify(clickWindow)
654
+ bot.clickWindow = clickWindow
655
655
  bot.putSelectedItemRange = putSelectedItemRange
656
656
  bot.putAway = putAway
657
657
  bot.closeWindow = closeWindow
658
- bot.transfer = callbackify(transfer)
659
- bot.openBlock = callbackify(openBlock)
660
- bot.openEntity = callbackify(openEntity)
661
- bot.moveSlotItem = callbackify(moveSlotItem)
658
+ bot.transfer = transfer
659
+ bot.openBlock = openBlock
660
+ bot.openEntity = openEntity
661
+ bot.moveSlotItem = moveSlotItem
662
662
  bot.updateHeldItem = updateHeldItem
663
663
  }
@@ -3,7 +3,7 @@ const assert = require('assert')
3
3
  const math = require('../math')
4
4
  const conv = require('../conversions')
5
5
  const { performance } = require('perf_hooks')
6
- const { callbackify, createDoneTask, createTask } = require('../promise_utils')
6
+ const { createDoneTask, createTask } = require('../promise_utils')
7
7
 
8
8
  const { Physics, PlayerState } = require('prismarine-physics')
9
9
 
@@ -223,7 +223,7 @@ function inject (bot, { physicsEnabled }) {
223
223
  }
224
224
  })
225
225
 
226
- bot.look = callbackify(async (yaw, pitch, force) => {
226
+ bot.look = async (yaw, pitch, force) => {
227
227
  if (!lookingTask.done) {
228
228
  lookingTask.finish() // finish the previous one
229
229
  }
@@ -245,15 +245,15 @@ function inject (bot, { physicsEnabled }) {
245
245
  }
246
246
 
247
247
  await lookingTask.promise
248
- })
248
+ }
249
249
 
250
- bot.lookAt = callbackify(async (point, force) => {
250
+ bot.lookAt = async (point, force) => {
251
251
  const delta = point.minus(bot.entity.position.offset(0, bot.entity.height, 0))
252
252
  const yaw = Math.atan2(-delta.x, -delta.z)
253
253
  const groundDistance = Math.sqrt(delta.x * delta.x + delta.z * delta.z)
254
254
  const pitch = Math.atan2(delta.y, groundDistance)
255
255
  await bot.look(yaw, pitch, force)
256
- })
256
+ }
257
257
 
258
258
  // player position and look (clientbound)
259
259
  bot._client.on('position', (packet) => {
@@ -1,4 +1,4 @@
1
- const { onceWithCleanup, callbackify } = require('../promise_utils')
1
+ const { onceWithCleanup } = require('../promise_utils')
2
2
 
3
3
  module.exports = inject
4
4
 
@@ -24,6 +24,6 @@ function inject (bot) {
24
24
  await placeBlockWithOptions(referenceBlock, faceVector, { swingArm: 'right' })
25
25
  }
26
26
 
27
- bot.placeBlock = callbackify(placeBlock)
27
+ bot.placeBlock = placeBlock
28
28
  bot._placeBlockWithOptions = placeBlockWithOptions
29
29
  }
@@ -1,5 +1,4 @@
1
1
  const assert = require('assert')
2
- const { callbackify } = require('../promise_utils')
3
2
 
4
3
  module.exports = inject
5
4
 
@@ -144,10 +143,10 @@ function inject (bot) {
144
143
  return bot.clickWindow(slot, 1, 0)
145
144
  }
146
145
 
147
- bot.equip = callbackify(equip)
148
- bot.unequip = callbackify(unequip)
149
- bot.toss = callbackify(toss)
150
- bot.tossStack = callbackify(tossStack)
146
+ bot.equip = equip
147
+ bot.unequip = unequip
148
+ bot.toss = toss
149
+ bot.tossStack = tossStack
151
150
  bot.setQuickBarSlot = setQuickBarSlot
152
151
  bot.getEquipmentDestSlot = getDestSlot
153
152
  bot.simpleClick = { leftMouse, rightMouse }
@@ -1,6 +1,5 @@
1
1
  const assert = require('assert')
2
2
  const { once } = require('events')
3
- const { callbackify } = require('../promise_utils')
4
3
 
5
4
  module.exports = inject
6
5
 
@@ -249,6 +248,6 @@ function inject (bot, { version }) {
249
248
  await bot.transfer(options)
250
249
  }
251
250
 
252
- bot.openVillager = callbackify(openVillager)
253
- bot.trade = callbackify(trade)
251
+ bot.openVillager = openVillager
252
+ bot.trade = trade
254
253
  }
@@ -1,13 +1,3 @@
1
- function callbackify (f) {
2
- return function (...args) {
3
- const cb = args[f.length]
4
- return f(...args).then(r => {
5
- if (cb) { cb(undefined, r) }
6
- return r
7
- }, err => { if (cb) { cb(err) } else throw err })
8
- }
9
- }
10
-
11
1
  function sleep (ms) {
12
2
  return new Promise(resolve => setTimeout(resolve, ms))
13
3
  }
@@ -92,7 +82,6 @@ function withTimeout (promise, timeout) {
92
82
  }
93
83
 
94
84
  module.exports = {
95
- callbackify,
96
85
  sleep,
97
86
  createTask,
98
87
  createDoneTask,