mineflayer 3.17.0 → 4.1.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/.github/workflows/ci.yml +1 -1
- package/README.md +1 -5
- package/docs/README.md +1 -5
- package/docs/api.md +135 -159
- package/docs/es/README_ES.md +6 -6
- package/docs/history.md +14 -0
- package/docs/tutorial.md +27 -78
- package/index.d.ts +39 -58
- package/lib/features.json +28 -28
- package/lib/plugins/anvil.js +4 -4
- package/lib/plugins/bed.js +2 -3
- package/lib/plugins/blocks.js +2 -2
- package/lib/plugins/book.js +4 -5
- package/lib/plugins/chat.js +1 -20
- package/lib/plugins/chest.js +3 -4
- package/lib/plugins/craft.js +1 -2
- package/lib/plugins/creative.js +4 -4
- package/lib/plugins/digging.js +2 -25
- package/lib/plugins/enchantment_table.js +5 -6
- package/lib/plugins/entities.js +3 -2
- package/lib/plugins/fishing.js +2 -2
- package/lib/plugins/furnace.js +6 -7
- package/lib/plugins/inventory.js +17 -15
- package/lib/plugins/physics.js +5 -5
- package/lib/plugins/place_block.js +2 -2
- package/lib/plugins/settings.js +24 -4
- package/lib/plugins/simple_inventory.js +4 -5
- package/lib/plugins/villager.js +2 -3
- package/lib/promise_utils.js +1 -25
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/lib/features.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{
|
|
8
8
|
"name": "spawner",
|
|
9
9
|
"description": "spawner is called spawner",
|
|
10
|
-
"versions": ["1.13", "1.18.
|
|
10
|
+
"versions": ["1.13", "1.18.2"]
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"name": "blockMetadata",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
{
|
|
18
18
|
"name": "blockStateId",
|
|
19
19
|
"description": "block metadata is encoded as state id",
|
|
20
|
-
"versions": ["1.13", "1.18.
|
|
20
|
+
"versions": ["1.13", "1.18.2"]
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"name": "creativeSleepNearMobs",
|
|
24
24
|
"description": "can sleep near mobs in creative",
|
|
25
|
-
"versions": ["1.13", "1.18.
|
|
25
|
+
"versions": ["1.13", "1.18.2"]
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"name": "fixedPointPosition",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
{
|
|
33
33
|
"name": "doublePosition",
|
|
34
34
|
"description": "Entity positions are represented with double",
|
|
35
|
-
"versions": ["1.9", "1.18.
|
|
35
|
+
"versions": ["1.9", "1.18.2"]
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "fixedPointDelta",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
{
|
|
43
43
|
"name": "fixedPointDelta128",
|
|
44
44
|
"description": "Delta of position are represented with fixed point numbers times 128",
|
|
45
|
-
"versions": ["1.9", "1.18.
|
|
45
|
+
"versions": ["1.9", "1.18.2"]
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"name": "customChannelMCPrefixed",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
{
|
|
53
53
|
"name": "customChannelIdentifier",
|
|
54
54
|
"description": "custom channel is an identifier starting in minecraft namespace",
|
|
55
|
-
"versions": ["1.13", "1.18.
|
|
55
|
+
"versions": ["1.13", "1.18.2"]
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "dimensionDataIsAvailable",
|
|
59
59
|
"description": "dimensionData is available, providing an additional information about the current dimension",
|
|
60
|
-
"versions": ["1.17", "1.18.
|
|
60
|
+
"versions": ["1.17", "1.18.2"]
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"name": "useItemWithBlockPlace",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
{
|
|
68
68
|
"name": "useItemWithOwnPacket",
|
|
69
69
|
"description": "use item is done with its own packet",
|
|
70
|
-
"versions": ["1.9", "1.18.
|
|
70
|
+
"versions": ["1.9", "1.18.2"]
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"name": "blockPlaceHasHeldItem",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
{
|
|
88
88
|
"name": "blockPlaceHasInsideBlock",
|
|
89
89
|
"description": "block_place packet has inside block",
|
|
90
|
-
"versions": ["1.14", "1.18.
|
|
90
|
+
"versions": ["1.14", "1.18.2"]
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"name": "teleportUsesPositionPacket",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
{
|
|
103
103
|
"name": "teleportUsesOwnPacket",
|
|
104
104
|
"description": "teleport is done using its own packet",
|
|
105
|
-
"versions": ["1.9", "1.18.
|
|
105
|
+
"versions": ["1.9", "1.18.2"]
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"name": "oneBlockForSeveralVariations",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
{
|
|
113
113
|
"name": "blockSchemeIsFlat",
|
|
114
114
|
"description": "all variations of a packet have their own id",
|
|
115
|
-
"versions": ["1.13", "1.18.
|
|
115
|
+
"versions": ["1.13", "1.18.2"]
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
"name": "tabCompleteHasNoToolTip",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
{
|
|
123
123
|
"name": "tabCompleteHasAToolTip",
|
|
124
124
|
"description": "tab complete has a tool tip",
|
|
125
|
-
"versions": ["1.13", "1.18.
|
|
125
|
+
"versions": ["1.13", "1.18.2"]
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"name": "effectAreMinecraftPrefixed",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "effectAreNotPrefixed",
|
|
134
134
|
"description": "effect are not prefixed",
|
|
135
|
-
"versions": ["1.13", "1.18.
|
|
135
|
+
"versions": ["1.13", "1.18.2"]
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "itemsAreAlsoBlocks",
|
|
@@ -142,12 +142,12 @@
|
|
|
142
142
|
{
|
|
143
143
|
"name": "itemsAreNotBlocks",
|
|
144
144
|
"description": "items are not block",
|
|
145
|
-
"versions": ["1.13", "1.18.
|
|
145
|
+
"versions": ["1.13", "1.18.2"]
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"name": "fishingBobberCorrectlyNamed",
|
|
149
149
|
"description": "the fishing hook entity is named fishing_bobber",
|
|
150
|
-
"versions": ["1.14", "1.18.
|
|
150
|
+
"versions": ["1.14", "1.18.2"]
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"name": "editBookIsPluginChannel",
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
{
|
|
158
158
|
"name": "hasEditBookPacket",
|
|
159
159
|
"description": "book editing is handled through a packet",
|
|
160
|
-
"versions": ["1.13", "1.18.
|
|
160
|
+
"versions": ["1.13", "1.18.2"]
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "clientUpdateBookIdWhenSign",
|
|
@@ -197,12 +197,12 @@
|
|
|
197
197
|
{
|
|
198
198
|
"name": "dimensionIsAWorld",
|
|
199
199
|
"description": "description is a world name (string)",
|
|
200
|
-
"versions": ["1.16.2", "1.18.
|
|
200
|
+
"versions": ["1.16.2", "1.18.2"]
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
"name": "dimensionDataIsAvailable",
|
|
204
204
|
"description": "dimensionData is available, describing additional dimension information",
|
|
205
|
-
"versions": ["1.17", "1.18.
|
|
205
|
+
"versions": ["1.17", "1.18.2"]
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"name": "doesntHaveChestType",
|
|
@@ -227,22 +227,22 @@
|
|
|
227
227
|
{
|
|
228
228
|
"name": "hasAttackCooldown",
|
|
229
229
|
"description": "if there is a cooldown after attacks to deal full damage",
|
|
230
|
-
"versions": ["1.9", "1.18.
|
|
230
|
+
"versions": ["1.9", "1.18.2"]
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"name": "usesLoginPacket",
|
|
234
234
|
"description": "uses the login packet as defined in mcData",
|
|
235
|
-
"versions": ["1.16", "1.18.
|
|
235
|
+
"versions": ["1.16", "1.18.2"]
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
"name": "usesMultiblockSingleLong",
|
|
239
239
|
"description": "in the multi_block_change packet is stored as a single number",
|
|
240
|
-
"versions": ["1.16.2", "1.18.
|
|
240
|
+
"versions": ["1.16.2", "1.18.2"]
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"name": "usesMultiblock3DChunkCoords",
|
|
244
244
|
"description": "in the multi_block_change packet, all 3 axis coords are defined",
|
|
245
|
-
"versions": ["1.16.2", "1.18.
|
|
245
|
+
"versions": ["1.16.2", "1.18.2"]
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
"name": "setBlockUsesMetadataNumber",
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
{
|
|
258
258
|
"name": "selectingTradeMovesItems",
|
|
259
259
|
"description": "selecting a trade automatically puts the required items into trading slots",
|
|
260
|
-
"versions": ["1.14", "1.18.
|
|
260
|
+
"versions": ["1.14", "1.18.2"]
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
263
|
"name": "resourcePackUsesHash",
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
{
|
|
273
273
|
"name": "teamUsesChatComponents",
|
|
274
274
|
"description": "teams use chatcomponents for formatting",
|
|
275
|
-
"versions": ["1.13", "1.18.
|
|
275
|
+
"versions": ["1.13", "1.18.2"]
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
278
|
"name": "teamUsesScoreboard",
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
{
|
|
288
288
|
"name": "enderCrystalNameNoCapsWithUnderscore",
|
|
289
289
|
"description": "this is when the end_crystal's entity name is end_crystal",
|
|
290
|
-
"versions": ["1.14", "1.18.
|
|
290
|
+
"versions": ["1.14", "1.18.2"]
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
"name": "entityNameUpperCaseNoUnderscore",
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
{
|
|
308
308
|
"name": "stateIdUsed",
|
|
309
309
|
"description": "starting in 1.17.1, actionId has been replaced with stateId",
|
|
310
|
-
"versions": ["1.17.1", "1.18.
|
|
310
|
+
"versions": ["1.17.1", "1.18.2"]
|
|
311
311
|
},
|
|
312
312
|
{
|
|
313
313
|
"name": "actionIdUsed",
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
{
|
|
318
318
|
"name": "setSlotAsTransaction",
|
|
319
319
|
"description": "use setslot as transaction instead of just hoping it'll work",
|
|
320
|
-
"versions": ["1.17", "1.18.
|
|
320
|
+
"versions": ["1.17", "1.18.2"]
|
|
321
321
|
},
|
|
322
322
|
{
|
|
323
323
|
"name": "armAnimationBeforeUse",
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
{
|
|
328
328
|
"name": "tallWorld",
|
|
329
329
|
"description": "world starts at -64 and ends at 384",
|
|
330
|
-
"versions": ["1.18", "1.18.
|
|
330
|
+
"versions": ["1.18", "1.18.2"]
|
|
331
331
|
},
|
|
332
332
|
{
|
|
333
333
|
"name": "sendStringifiedSignText",
|
package/lib/plugins/anvil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
|
-
const {
|
|
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 =
|
|
109
|
-
anvil.rename =
|
|
108
|
+
anvil.combine = combine
|
|
109
|
+
anvil.rename = rename
|
|
110
110
|
|
|
111
111
|
return anvil
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
bot.openAnvil =
|
|
114
|
+
bot.openAnvil = openAnvil
|
|
115
115
|
}
|
package/lib/plugins/bed.js
CHANGED
|
@@ -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 =
|
|
178
|
-
bot.sleep =
|
|
176
|
+
bot.wake = wake
|
|
177
|
+
bot.sleep = sleep
|
|
179
178
|
bot.isABed = isABed
|
|
180
179
|
}
|
package/lib/plugins/blocks.js
CHANGED
|
@@ -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
|
|
4
|
+
const { onceWithCleanup } = require('../promise_utils')
|
|
5
5
|
|
|
6
6
|
const { OctahedronIterator } = require('prismarine-world').iterators
|
|
7
7
|
|
|
@@ -548,7 +548,7 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
548
548
|
bot.canSeeBlock = canSeeBlock
|
|
549
549
|
bot.blockAt = blockAt
|
|
550
550
|
bot._updateBlockState = updateBlockState
|
|
551
|
-
bot.waitForChunksToLoad =
|
|
551
|
+
bot.waitForChunksToLoad = waitForChunksToLoad
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
function onesInShort (n) {
|
package/lib/plugins/book.js
CHANGED
|
@@ -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 =
|
|
85
|
+
bot.writeBook = async (slot, pages) => {
|
|
87
86
|
await write(slot, pages, null, null, false)
|
|
88
|
-
}
|
|
87
|
+
}
|
|
89
88
|
|
|
90
|
-
bot.signBook =
|
|
89
|
+
bot.signBook = async (slot, pages, author, title) => {
|
|
91
90
|
await write(slot, pages, author, title, true)
|
|
92
|
-
}
|
|
91
|
+
}
|
|
93
92
|
}
|
package/lib/plugins/chat.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { once } = require('events')
|
|
2
|
-
const { printCallbackDepreciation } = require('../promise_utils')
|
|
3
2
|
|
|
4
3
|
module.exports = inject
|
|
5
4
|
|
|
@@ -170,7 +169,7 @@ function inject (bot, options) {
|
|
|
170
169
|
chatWithHeader('', message)
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
bot.tabComplete =
|
|
172
|
+
bot.tabComplete = tabComplete
|
|
174
173
|
|
|
175
174
|
function addDefaultPatterns () {
|
|
176
175
|
if (!defaultChatPatterns) return
|
|
@@ -194,21 +193,3 @@ function inject (bot, options) {
|
|
|
194
193
|
}
|
|
195
194
|
bot.awaitMessage = awaitMessage
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
function callbackify (f) { // specifically for this function because cb isn't the last parameter
|
|
199
|
-
return function (...args) {
|
|
200
|
-
const cb = args[1]
|
|
201
|
-
args.splice(1, 1)
|
|
202
|
-
return f(...args).then(r => {
|
|
203
|
-
if (cb) {
|
|
204
|
-
printCallbackDepreciation()
|
|
205
|
-
cb(undefined, r)
|
|
206
|
-
} return r
|
|
207
|
-
}, err => {
|
|
208
|
-
if (cb) {
|
|
209
|
-
printCallbackDepreciation()
|
|
210
|
-
cb(err)
|
|
211
|
-
} else throw err
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
}
|
package/lib/plugins/chest.js
CHANGED
|
@@ -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 =
|
|
30
|
-
bot.openChest =
|
|
31
|
-
bot.openDispenser =
|
|
28
|
+
bot.openContainer = openContainer
|
|
29
|
+
bot.openChest = openContainer
|
|
30
|
+
bot.openDispenser = openContainer
|
|
32
31
|
}
|
package/lib/plugins/craft.js
CHANGED
|
@@ -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 =
|
|
228
|
+
bot.craft = craft
|
|
230
229
|
bot.recipesFor = recipesFor
|
|
231
230
|
bot.recipesAll = recipesAll
|
|
232
231
|
}
|
package/lib/plugins/creative.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { Vec3 } = require('vec3')
|
|
3
|
-
const {
|
|
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:
|
|
14
|
-
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
|
|
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
|
|
package/lib/plugins/digging.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { performance } = require('perf_hooks')
|
|
2
|
-
const { createDoneTask, createTask
|
|
2
|
+
const { createDoneTask, createTask } = require('../promise_utils')
|
|
3
3
|
const BlockFaces = require('prismarine-world').iterators.BlockFace
|
|
4
4
|
const { Vec3 } = require('vec3')
|
|
5
5
|
|
|
@@ -198,35 +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 =
|
|
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 => {
|
|
217
|
-
if (cb) {
|
|
218
|
-
printCallbackDepreciation()
|
|
219
|
-
cb(undefined, r)
|
|
220
|
-
} return r
|
|
221
|
-
}, err => {
|
|
222
|
-
if (cb) {
|
|
223
|
-
printCallbackDepreciation()
|
|
224
|
-
cb(err)
|
|
225
|
-
} else throw err
|
|
226
|
-
})
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
207
|
function noop (err) {
|
|
231
208
|
if (err) throw err
|
|
232
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 =
|
|
19
|
-
enchantmentTable.takeTargetItem =
|
|
20
|
-
enchantmentTable.putTargetItem =
|
|
21
|
-
enchantmentTable.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 =
|
|
102
|
+
bot.openEnchantmentTable = openEnchantmentTable
|
|
104
103
|
}
|
package/lib/plugins/entities.js
CHANGED
|
@@ -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
|
|
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
|
|
605
|
+
sneaking
|
|
605
606
|
})
|
|
606
607
|
}
|
|
607
608
|
}
|
package/lib/plugins/fishing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
|
-
const {
|
|
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 =
|
|
57
|
+
bot.fish = fish
|
|
58
58
|
}
|
package/lib/plugins/furnace.js
CHANGED
|
@@ -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 =
|
|
29
|
-
furnace.takeFuel =
|
|
30
|
-
furnace.takeOutput =
|
|
31
|
-
furnace.putInput =
|
|
32
|
-
furnace.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 =
|
|
120
|
+
bot.openFurnace = openFurnace
|
|
122
121
|
}
|
package/lib/plugins/inventory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { Vec3 } = require('vec3')
|
|
3
3
|
const { once } = require('events')
|
|
4
|
-
const {
|
|
4
|
+
const { sleep, createDoneTask, createTask, withTimeout } = require('../promise_utils')
|
|
5
5
|
|
|
6
6
|
module.exports = inject
|
|
7
7
|
|
|
@@ -306,36 +306,38 @@ function inject (bot, { version, hideErrors }) {
|
|
|
306
306
|
window.emit('close')
|
|
307
307
|
closeWindow(window)
|
|
308
308
|
}
|
|
309
|
-
|
|
309
|
+
|
|
310
|
+
window.withdraw = async (itemType, metadata, count, nbt) => {
|
|
310
311
|
if (bot.inventory.emptySlotCount() === 0) {
|
|
311
312
|
throw new Error('Unable to withdraw, Bot inventory is full.')
|
|
312
313
|
}
|
|
313
|
-
|
|
314
314
|
const options = {
|
|
315
315
|
window,
|
|
316
316
|
itemType,
|
|
317
317
|
metadata,
|
|
318
318
|
count,
|
|
319
|
+
nbt,
|
|
319
320
|
sourceStart: 0,
|
|
320
321
|
sourceEnd: window.inventoryStart,
|
|
321
322
|
destStart: window.inventoryStart,
|
|
322
323
|
destEnd: window.inventoryEnd
|
|
323
324
|
}
|
|
324
325
|
await transfer(options)
|
|
325
|
-
}
|
|
326
|
-
window.deposit =
|
|
326
|
+
}
|
|
327
|
+
window.deposit = async (itemType, metadata, count, nbt) => {
|
|
327
328
|
const options = {
|
|
328
329
|
window: window,
|
|
329
330
|
itemType,
|
|
330
331
|
metadata,
|
|
331
332
|
count,
|
|
333
|
+
nbt,
|
|
332
334
|
sourceStart: window.inventoryStart,
|
|
333
335
|
sourceEnd: window.inventoryEnd,
|
|
334
336
|
destStart: 0,
|
|
335
337
|
destEnd: window.inventoryStart
|
|
336
338
|
}
|
|
337
339
|
await transfer(options)
|
|
338
|
-
}
|
|
340
|
+
}
|
|
339
341
|
}
|
|
340
342
|
|
|
341
343
|
async function openBlock (block) {
|
|
@@ -643,21 +645,21 @@ function inject (bot, { version, hideErrors }) {
|
|
|
643
645
|
bot.emit(`setWindowItems:${window.id}`)
|
|
644
646
|
})
|
|
645
647
|
|
|
646
|
-
bot.activateBlock =
|
|
647
|
-
bot.activateEntity =
|
|
648
|
-
bot.activateEntityAt =
|
|
649
|
-
bot.consume =
|
|
648
|
+
bot.activateBlock = activateBlock
|
|
649
|
+
bot.activateEntity = activateEntity
|
|
650
|
+
bot.activateEntityAt = activateEntityAt
|
|
651
|
+
bot.consume = consume
|
|
650
652
|
bot.activateItem = activateItem
|
|
651
653
|
bot.deactivateItem = deactivateItem
|
|
652
654
|
|
|
653
655
|
// not really in the public API
|
|
654
|
-
bot.clickWindow =
|
|
656
|
+
bot.clickWindow = clickWindow
|
|
655
657
|
bot.putSelectedItemRange = putSelectedItemRange
|
|
656
658
|
bot.putAway = putAway
|
|
657
659
|
bot.closeWindow = closeWindow
|
|
658
|
-
bot.transfer =
|
|
659
|
-
bot.openBlock =
|
|
660
|
-
bot.openEntity =
|
|
661
|
-
bot.moveSlotItem =
|
|
660
|
+
bot.transfer = transfer
|
|
661
|
+
bot.openBlock = openBlock
|
|
662
|
+
bot.openEntity = openEntity
|
|
663
|
+
bot.moveSlotItem = moveSlotItem
|
|
662
664
|
bot.updateHeldItem = updateHeldItem
|
|
663
665
|
}
|
package/lib/plugins/physics.js
CHANGED
|
@@ -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 {
|
|
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 =
|
|
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 =
|
|
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) => {
|