forked from PrismarineJS/mineflayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
837 lines (662 loc) · 20.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
import { EventEmitter } from 'events'
import TypedEmitter from 'typed-emitter'
import { Client, ClientOptions } from 'minecraft-protocol'
import { Vec3 } from 'vec3'
import { Item } from 'prismarine-item'
import { Window } from 'prismarine-windows'
import { Recipe } from 'prismarine-recipe'
import { Block } from 'prismarine-block'
import { Entity } from 'prismarine-entity'
import { ChatMessage } from 'prismarine-chat'
export function createBot (options: BotOptions): Bot
export interface BotOptions extends ClientOptions {
logErrors?: boolean
hideErrors?: boolean
loadInternalPlugins?: boolean
plugins?: PluginOptions
chat?: ChatLevel
colorsEnabled?: boolean
viewDistance?: ViewDistance
mainHand?: MainHands
difficulty?: number
chatLengthLimit?: number
physicsEnabled?: boolean
client?: Client
brand?: string
}
export type ChatLevel = 'enabled' | 'commandsOnly' | 'disabled'
export type ViewDistance = 'far' | 'normal' | 'short' | 'tiny'
export type MainHands = 'left' | 'right'
export interface PluginOptions {
[plugin: string]: boolean | Plugin
}
export type Plugin = (bot: Bot, options: BotOptions) => void
interface BotEvents {
chat: (
username: string,
message: string,
translate: string | null,
jsonMsg: ChatMessage,
matches: string[] | null
) => void
whisper: (
username: string,
message: string,
translate: string | null,
jsonMsg: ChatMessage,
matches: string[] | null
) => void
actionBar: (jsonMsg: ChatMessage) => void
error: (err: Error) => void
message: (jsonMsg: ChatMessage, position: string) => void
messagestr: (message: string, position: string, jsonMsg: ChatMessage) => void
unmatchedMessage: (stringMsg: string, jsonMsg: ChatMessage) => void
inject_allowed: () => void
login: () => void
spawn: () => void
respawn: () => void
game: () => void
title: (text: string) => void
rain: () => void
time: () => void
kicked: (reason: string, loggedIn: boolean) => void
end: () => void
spawnReset: () => void
death: () => void
health: () => void
breath: () => void
entitySwingArm: (entity: Entity) => void
entityHurt: (entity: Entity) => void
entityDead: (entity: Entity) => void
entityTaming: (entity: Entity) => void
entityTamed: (entity: Entity) => void
entityShakingOffWater: (entity: Entity) => void
entityEatingGrass: (entity: Entity) => void
entityWake: (entity: Entity) => void
entityEat: (entity: Entity) => void
entityCriticalEffect: (entity: Entity) => void
entityMagicCriticalEffect: (entity: Entity) => void
entityCrouch: (entity: Entity) => void
entityUncrouch: (entity: Entity) => void
entityEquip: (entity: Entity) => void
entitySleep: (entity: Entity) => void
entitySpawn: (entity: Entity) => void
itemDrop: (entity: Entity) => void
playerCollect: (collector: Entity, collected: Entity) => void
entityAttributes: (entity: Entity) => void
entityGone: (entity: Entity) => void
entityMoved: (entity: Entity) => void
entityDetach: (entity: Entity, vehicle: Entity) => void
entityAttach: (entity: Entity, vehicle: Entity) => void
entityUpdate: (entity: Entity) => void
entityEffect: (entity: Entity, effect: Effect) => void
entityEffectEnd: (entity: Entity, effect: Effect) => void
playerJoined: (player: Player) => void
playerUpdated: (player: Player) => void
playerLeft: (entity: Player) => void
blockUpdate: (oldBlock: Block | null, newBlock: Block) => void
'blockUpdate:(x, y, z)': (oldBlock: Block | null, newBlock: Block) => void
chunkColumnLoad: (entity: Vec3) => void
chunkColumnUnload: (entity: Vec3) => void
soundEffectHeard: (
soundName: string,
position: Vec3,
volume: number,
pitch: number
) => void
hardcodedSoundEffectHeard: (
soundId: number,
soundCategory: number,
position: Vec3,
volume: number,
pitch: number
) => void
noteHeard: (block: Block, instrument: Instrument, pitch: number) => void
pistonMove: (block: Block, isPulling: number, direction: number) => void
chestLidMove: (block: Block, isOpen: number) => void
blockBreakProgressObserved: (block: Block, destroyStage: number) => void
blockBreakProgressEnd: (block: Block) => void
diggingCompleted: (block: Block) => void
diggingAborted: (block: Block) => void
move: () => void
forcedMove: () => void
mount: () => void
dismount: (vehicle: Entity) => void
windowOpen: (vehicle: Window) => void
windowClose: (vehicle: Window) => void
sleep: () => void
wake: () => void
experience: () => void
physicsTick: () => void
physicTick: () => void
scoreboardCreated: (scoreboard: ScoreBoard) => void
scoreboardDeleted: (scoreboard: ScoreBoard) => void
scoreboardTitleChanged: (scoreboard: ScoreBoard) => void
scoreUpdated: (scoreboard: ScoreBoard, item: number) => void
scoreRemoved: (scoreboard: ScoreBoard, item: number) => void
scoreboardPosition: (position: DisplaySlot, scoreboard: ScoreBoard) => void
teamCreated: (team: Team) => void
teamRemoved: (team: Team) => void
teamUpdated: (team: Team) => void
teamMemberAdded: (team: Team) => void
teamMemberRemoved: (team: Team) => void
bossBarCreated: (bossBar: BossBar) => void
bossBarDeleted: (bossBar: BossBar) => void
bossBarUpdated: (bossBar: BossBar) => void
resourcePack: (url: string, hash: string) => void
}
export interface Bot extends TypedEmitter<BotEvents> {
username: string
protocolVersion: string
majorVersion: string
version: string
entity: Entity
entities: { [id: string]: Entity }
spawnPoint: Vec3
game: GameState
player: Player
players: { [username: string]: Player }
isRaining: boolean
chatPatterns: ChatPattern[]
settings: GameSettings
experience: Experience
health: number
food: number
foodSaturation: number
oxygenLevel: number
physics: PhysicsOptions
physicsEnabled: boolean
time: Time
quickBarSlot: number
inventory: Window
targetDigBlock: Block
isSleeping: boolean
scoreboards: { [name: string]: ScoreBoard }
scoreboard: { [slot in DisplaySlot]: ScoreBoard }
teamMap: { [name: string]: Team }
controlState: ControlStateStatus
creative: creativeMethods
world: any
_client: Client
heldItem: Item | null
currentWindow: Window | null
simpleClick: simpleClick
connect: (options: BotOptions) => void
supportFeature: (feature: string) => boolean
end: () => void
blockAt: (point: Vec3) => Block | null
blockInSight: (maxSteps: number, vectorLength: number) => Block | null
blockAtCursor: (maxDistance?: number, matcher?: Function) => Block | null
canSeeBlock: (block: Block) => boolean
findBlock: (options: FindBlockOptions) => Block | null
findBlocks: (options: FindBlockOptions) => Vec3[]
canDigBlock: (block: Block) => boolean
recipesFor: (
itemType: number,
metadata: number | null,
minResultCount: number | null,
craftingTable: Block | boolean | null
) => Recipe[]
recipesAll: (
itemType: number,
metadata: number | null,
craftingTable: Block | boolean | null
) => Recipe[]
quit: (reason?: string) => void
tabComplete: (
str: string,
cb: (matches: string[]) => void,
assumeCommand?: boolean,
sendBlockInSight?: boolean
) => Promise<string[]>
chat: (message: string) => void
whisper: (username: string, message: string) => void
chatAddPattern: (pattern: RegExp, chatType: string, description?: string) => number
setSettings: (options: Partial<GameSettings>) => void
loadPlugin: (plugin: Plugin) => void
loadPlugins: (plugins: Plugin[]) => void
hasPlugin: (plugin: Plugin) => boolean
sleep: (bedBlock: Block, cb?: (err?: Error) => void) => Promise<void>
isABed: (bedBlock: Block) => void
wake: (cb?: (err?: Error) => void) => Promise<void>
setControlState: (control: ControlState, state: boolean) => void
getControlState: (control: ControlState) => boolean
clearControlStates: () => void
lookAt: (point: Vec3, force?: boolean, callback?: () => void) => Promise<void>
look: (
yaw: number,
pitch: number,
force?: boolean,
callback?: () => void
) => Promise<void>
updateSign: (block: Block, text: string) => void
equip: (
item: Item | number,
destination: EquipmentDestination | null,
callback?: (error?: Error) => void
) => Promise<void>
unequip: (
destination: EquipmentDestination | null,
callback?: () => void
) => Promise<void>
tossStack: (item: Item, callback?: (error?: Error) => void) => Promise<void>
toss: (
itemType: number,
metadata: number | null,
count: number | null,
callback?: (err?: Error) => void
) => Promise<void>
dig: ((block: Block, forceLook?: boolean | 'ignore', callback?: (err?: Error) => void) => Promise<void>) & ((block: Block, forceLook: boolean | 'ignore', digFace: 'auto' | Vec3 | 'raycast', callback?: (err?: Error) => void) => Promise<void>)
stopDigging: () => void
digTime: (block: Block) => number
placeBlock: (referenceBlock: Block, faceVector: Vec3, cb?: () => void) => Promise<void>
placeEntity: (referenceBlock: Block, faceVector: Vec3) => Promise<Entity>
activateBlock: (block: Block, callback?: (err?: Error) => void) => Promise<void>
activateEntity: (block: Entity, callback?: (err?: Error) => void) => Promise<void>
activateEntityAt: (block: Entity, position: Vec3, callback?: (err?: Error) => void) => Promise<void>
consume: (callback?: (err?: Error) => void) => Promise<void>
fish: (callback?: (err?: Error) => void) => Promise<void>
activateItem: (offhand?: boolean) => void
deactivateItem: () => void
useOn: (targetEntity: Entity) => void
attack: (entity: Entity) => void
swingArm: (hand: 'left' | 'right' | undefined, showHand?: boolean) => void
mount: (entity: Entity) => void
dismount: () => void
moveVehicle: (left: number, forward: number) => void
setQuickBarSlot: (slot: number) => void
craft: (
recipe: Recipe,
count: number | null,
craftingTable: Block,
callback?: () => void
) => Promise<void>
writeBook: (
slot: number,
pages: string[],
callback?: (err?: Error) => void
) => Promise<void>
openChest: (chest: Block | Entity) => Promise<ContainerWindow>
openFurnace: (furnace: Block) => Promise<Furnace>
openDispenser: (dispenser: Block) => Promise<ContainerWindow>
openEnchantmentTable: (enchantmentTable: Block) => Promise<EnchantmentTable>
openAnvil: (anvil: Block) => Promise<Anvil>
openVillager: (
villager: Entity
) => Villager
trade: (
villagerInstance: Villager,
tradeIndex: string | number,
times?: number,
cb?: (err?: Error) => void
) => Promise<void>
setCommandBlock: (pos: Vec3, command: string, trackOutput: boolean) => void
clickWindow: (
slot: number,
mouseButton: number,
mode: number,
cb?: (err?: Error) => void
) => Promise<void>
putSelectedItemRange: (
start: number,
end: number,
window: Window,
slot: any,
cb?: (err?: Error) => void
) => Promise<void>
putAway: (slot: number, cb?: (err?: Error) => void) => Promise<void>
closeWindow: (window: Window) => void
transfer: (options: TransferOptions, cb?: (err?: Error) => void) => Promise<void>
openBlock: (block: Block, Class: new () => EventEmitter) => Promise<void>
openEntity: (block: Entity, Class: new () => EventEmitter) => Promise<void>
moveSlotItem: (
sourceSlot: number,
destSlot: number,
cb?: (err?: Error) => void
) => Promise<void>
updateHeldItem: () => void
getEquipmentDestSlot: (destination: string) => number
waitForChunksToLoad: (cb?: (err?: Error) => void) => Promise<void>
nearestEntity: (filter?: (entity: Entity) => boolean) => Entity | null
waitForTicks: (ticks: number) => Promise<void>
addChatPattern: (name: string, pattern: RegExp, options?: chatPatternOptions) => number
addChatPatternSet: (name: string, patterns: RegExp[], options?: chatPatternOptions) => number
removeChatPattern: (name: string | number) => void
awaitMessage: (...args: string[] | RegExp[]) => Promise<string>
acceptResourcePack: () => void
denyResourcePack: () => void
}
export interface simpleClick {
leftMouse: (slot: number) => Promise<void>
rightMouse: (slot: number) => Promise<void>
}
export interface chatPatternOptions {
repeat: boolean
parse: boolean
}
export interface GameState {
levelType: LevelType
gameMode: GameMode
hardcore: boolean
dimension: Dimension
difficulty: Difficulty
maxPlayers: number
}
export type LevelType =
| 'default'
| 'flat'
| 'largeBiomes'
| 'amplified'
| 'customized'
| 'buffet'
| 'default_1_1'
export type GameMode = 'survival' | 'creative' | 'adventure'
export type Dimension = 'minecraft:nether' | 'minecraft:overworld' | 'minecraft:end'
export type Difficulty = 'peaceful' | 'easy' | 'normal' | 'hard'
export interface Player {
uuid: string
username: string
displayName: ChatMessage
gamemode: number
ping: number
entity: Entity
}
export interface ChatPattern {
pattern: RegExp
type: string
description: string
}
export interface SkinParts {
showCape: boolean
showJacket: boolean
showLeftSleeve: boolean
showRightSleeve: boolean
showLeftPants: boolean
showRightPants: boolean
showHat: boolean
}
export interface GameSettings {
chat: ChatLevel
colorsEnabled: boolean
viewDistance: ViewDistance
difficulty: number
skinParts: SkinParts
mainHand: MainHands
}
export interface Experience {
level: number
points: number
progress: number
}
export interface PhysicsOptions {
maxGroundSpeed: number
terminalVelocity: number
walkingAcceleration: number
gravity: number
groundFriction: number
playerApothem: number
playerHeight: number
jumpSpeed: number
yawSpeed: number
sprintSpeed: number
maxGroundSpeedSoulSand: number
maxGroundSpeedWater: number
}
export interface Time {
doDaylightCycle: boolean
bigTime: BigInt
time: number
timeOfDay: number
day: number
isDay: boolean
moonPhase: number
bigAge: BigInt
age: number
}
export interface ControlStateStatus {
forward: boolean
back: boolean
left: boolean
right: boolean
jump: boolean
sprint: boolean
sneak: boolean
}
export type ControlState =
| 'forward'
| 'back'
| 'left'
| 'right'
| 'jump'
| 'sprint'
| 'sneak'
export interface Effect {
id: number
amplifier: number
duration: number
}
export interface Instrument {
id: number
name: 'harp' | 'doubleBass' | 'snareDrum' | 'sticks' | 'bassDrum'
}
export interface FindBlockOptions {
point?: Vec3
matching: number | number[] | ((block: Block) => boolean)
maxDistance?: number
count?: number
useExtraInfo?: boolean
}
export type EquipmentDestination = 'hand' | 'head' | 'torso' | 'legs' | 'feet' | 'off-hand'
export interface TransferOptions {
window: Window
itemType: number
metadata: number | null
sourceStart: number
sourceEnd: number
destStart: number
destEnd: number
}
export interface creativeMethods {
setInventorySlot: (
slot: number,
item: Item | null,
callback?: (error?: Error) => void
) => Promise<void>
flyTo: (destination: Vec3, cb?: () => void) => Promise<void>
startFlying: () => void
stopFlying: () => void
}
export class Location {
floored: Vec3
blockPoint: Vec3
chunkCorner: Vec3
blockIndex: number
biomeBlockIndex: number
chunkYIndex: number
constructor (absoluteVector: Vec3);
}
export class Painting {
id: number
position: Vec3
name: string
direction: Vec3
constructor (id: number, position: Vec3, name: string, direction: Vec3);
}
interface StorageEvents {
open: () => void
close: () => void
updateSlot: (oldItem: Item | null, newItem: Item) => void
}
interface FurnaceEvents extends StorageEvents {
update: () => void
}
interface ConditionalStorageEvents extends StorageEvents {
ready: () => void
}
type ContainerWindow = Anvil | Furnace | Chest | EnchantmentTable | Villager
export class Chest extends (EventEmitter as new () => TypedEmitter<StorageEvents>) {
window: object | /* prismarine-windows ChestWindow */ null
constructor ();
close (): void;
deposit (
itemType: number,
metadata: number | null,
count: number | null,
cb?: (err?: Error) => void
): Promise<void>;
withdraw (
itemType: number,
metadata: number | null,
count: number | null,
cb?: (err?: Error) => void
): Promise<void>;
count (itemType: number, metadata: number | null): number;
items (): Item[];
}
export class Furnace extends (EventEmitter as new () => TypedEmitter<FurnaceEvents>) {
fuel: number
progress: number
constructor ();
close (): void;
takeInput (cb: (err: Error | null, item: Item) => void): Promise<Item>;
takeFuel (cb: (err: Error | null, item: Item) => void): Promise<Item>;
takeOutput (cb: (err: Error | null, item: Item) => void): Promise<Item>;
putInput (
itemType: number,
metadata: number | null,
count: number,
cb?: (err?: Error) => void
): Promise<void>;
putFuel (
itemType: number,
metadata: number | null,
count: number,
cb?: (err?: Error) => void
): Promise<void>;
inputItem (): Item;
fuelItem (): Item;
outputItem (): Item;
}
export class Dispenser extends (EventEmitter as new () => TypedEmitter<StorageEvents>) {
constructor ();
close (): void;
deposit (
itemType: number,
metadata: number | null,
count: number | null,
cb?: (err?: Error) => void
): Promise<void>;
withdraw (
itemType: number,
metadata: number | null,
count: number | null,
cb?: (err?: Error) => void
): Promise<void>;
count (itemType: number, metadata: number | null): number;
items (): Item[];
}
export class EnchantmentTable extends (EventEmitter as new () => TypedEmitter<ConditionalStorageEvents>) {
enchantments: Enchantment[]
constructor ();
close (): void;
targetItem (): Item;
enchant (
choice: string | number,
cb?: (err: Error | null, item: Item) => void
): Promise<Item>;
takeTargetItem (cb?: (err: Error | null, item: Item) => void): Promise<Item>;
putTargetItem (item: Item, cb?: (err: Error | null) => void): Promise<Item>;
putLapis (item: Item, cb?: (err: Error | null) => void): Promise<Item>;
}
export class Anvil {
combine (itemOne: Item, itemTwo: Item, name?: string): Promise<void>
rename (item: Item, name?: string): Promise<void>
}
export interface Enchantment {
level: number
}
export class Villager extends (EventEmitter as new () => TypedEmitter<ConditionalStorageEvents>) {
trades: VillagerTrade[]
constructor ();
close (): void;
}
export interface VillagerTrade {
firstInput: Item
output: Item
hasSecondItem: boolean
secondaryInput: Item | null
disabled: boolean
tooluses: number
maxTradeuses: number
}
export class ScoreBoard {
name: string
title: string
itemsMap: { [name: string]: ScoreBoardItem }
items: ScoreBoardItem[]
constructor (packet: object);
setTitle (title: string): void;
add (name: string, value: number, displayName: ChatMessage): ScoreBoardItem;
remove (name: string): ScoreBoardItem;
}
export interface ScoreBoardItem {
name: string
displayName: ChatMessage
value: number
}
export class Team {
name: ChatMessage
friendlyFire: number
nameTagVisibility: string
collisionRule: string
color: string
prefix: ChatMessage
suffix: ChatMessage
constructor (packet: object);
parseMessage (value: string): ChatMessage;
add (name: string, value: number): void;
remove (name: string): void;
update (name: string, friendlyFire: boolean, nameTagVisibility: string, collisionRule: string, formatting: number, prefix: string, suffix: string): void;
displayName (member: string);
}
export type DisplaySlot =
| 'list'
| 'sidebar'
| 'belowName'
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
export class BossBar {
entityUUID: string
title: ChatMessage
health: number
dividers: number
color: 'pink' | 'blue' | 'red' | 'green' | 'yellow' | 'purple' | 'white'
shouldDarkenSky: boolean
isDragonBar: boolean
shouldCreateFog: boolean
constructor (
uuid: string,
title: string,
health: number,
dividers: number,
color: number,
flags: number
);
}
export var supportedVersions: string[]
export var testedVersions: string[]
export function supportFeature (feature: string, version: string): boolean