mineflayer 3.10.0 → 3.12.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.
Files changed (46) hide show
  1. package/.github/FUNDING.yml +0 -2
  2. package/.github/workflows/ci.yml +20 -16
  3. package/README.md +16 -15
  4. package/docs/README.md +16 -15
  5. package/docs/api.md +50 -27
  6. package/docs/es/README_ES.md +1 -1
  7. package/docs/es/api_es.md +34 -18
  8. package/docs/fr/README_FR.md +1 -1
  9. package/docs/history.md +28 -0
  10. package/docs/ru/README_RU.md +1 -1
  11. package/docs/ru/api_ru.md +1 -1
  12. package/docs/tr/README_TR.md +1 -1
  13. package/docs/zh/README_ZH_CN.md +1 -1
  14. package/examples/chatterbox.js +1 -1
  15. package/examples/discord.js +15 -5
  16. package/examples/plugins/afk.js +50 -37
  17. package/examples/python/basic.py +2 -2
  18. package/examples/python/chatterbox.py +1 -1
  19. package/examples/screenshot-with-node-canvas-webgl/screenshot.js +2 -2
  20. package/index.d.ts +108 -134
  21. package/lib/conversions.js +1 -1
  22. package/lib/features.json +57 -27
  23. package/lib/loader.js +5 -4
  24. package/lib/plugins/bed.js +1 -1
  25. package/lib/plugins/block_actions.js +19 -7
  26. package/lib/plugins/blocks.js +17 -4
  27. package/lib/plugins/chat.js +5 -6
  28. package/lib/plugins/command_block.js +1 -1
  29. package/lib/plugins/craft.js +10 -18
  30. package/lib/plugins/creative.js +2 -2
  31. package/lib/plugins/digging.js +15 -6
  32. package/lib/plugins/enchantment_table.js +4 -2
  33. package/lib/plugins/entities.js +13 -8
  34. package/lib/plugins/explosion.js +3 -1
  35. package/lib/plugins/fishing.js +2 -2
  36. package/lib/plugins/game.js +55 -50
  37. package/lib/plugins/inventory.js +164 -40
  38. package/lib/plugins/physics.js +16 -5
  39. package/lib/plugins/place_block.js +7 -6
  40. package/lib/plugins/ray_trace.js +10 -0
  41. package/lib/plugins/simple_inventory.js +1 -1
  42. package/lib/plugins/sound.js +1 -1
  43. package/lib/plugins/spawn_point.js +1 -1
  44. package/lib/plugins/villager.js +57 -42
  45. package/lib/version.js +3 -3
  46. package/package.json +23 -22
package/index.d.ts CHANGED
@@ -7,7 +7,9 @@ import { Window } from 'prismarine-windows'
7
7
  import { Recipe } from 'prismarine-recipe'
8
8
  import { Block } from 'prismarine-block'
9
9
  import { Entity } from 'prismarine-entity'
10
+ import { ChatMessage } from 'prismarine-chat'
10
11
 
12
+ export function createBot (options: { client: Client } & Partial<BotOptions>): Bot
11
13
  export function createBot (options: BotOptions): Bot
12
14
 
13
15
  export interface BotOptions extends ClientOptions {
@@ -23,6 +25,8 @@ export interface BotOptions extends ClientOptions {
23
25
  chatLengthLimit?: number
24
26
  physicsEnabled?: boolean
25
27
  client?: Client
28
+ brand?: string
29
+ defaultChatPatterns?: boolean
26
30
  }
27
31
 
28
32
  export type ChatLevel = 'enabled' | 'commandsOnly' | 'disabled'
@@ -42,112 +46,111 @@ interface BotEvents {
42
46
  translate: string | null,
43
47
  jsonMsg: ChatMessage,
44
48
  matches: string[] | null
45
- ) => void
49
+ ) => Promise<void> | void
46
50
  whisper: (
47
51
  username: string,
48
52
  message: string,
49
53
  translate: string | null,
50
54
  jsonMsg: ChatMessage,
51
55
  matches: string[] | null
52
- ) => void
53
- actionBar: (jsonMsg: ChatMessage) => void
54
- error: (err: Error) => void
55
- message: (jsonMsg: ChatMessage, position: string) => void
56
- messagestr: (message: string, position: string, jsonMsg: ChatMessage) => void
57
- unmatchedMessage: (stringMsg: string, jsonMsg: ChatMessage) => void
58
- inject_allowed: () => void
59
- login: () => void
60
- spawn: () => void
61
- respawn: () => void
62
- game: () => void
63
- title: (text: string) => void
64
- rain: () => void
65
- time: () => void
66
- kicked: (reason: string, loggedIn: boolean) => void
67
- end: () => void
68
- spawnReset: () => void
69
- death: () => void
70
- health: () => void
71
- breath: () => void
72
- entitySwingArm: (entity: Entity) => void
73
- entityHurt: (entity: Entity) => void
74
- entityDead: (entity: Entity) => void
75
- entityTaming: (entity: Entity) => void
76
- entityTamed: (entity: Entity) => void
77
- entityShakingOffWater: (entity: Entity) => void
78
- entityEatingGrass: (entity: Entity) => void
79
- entityWake: (entity: Entity) => void
80
- entityEat: (entity: Entity) => void
81
- entityCriticalEffect: (entity: Entity) => void
82
- entityMagicCriticalEffect: (entity: Entity) => void
83
- entityCrouch: (entity: Entity) => void
84
- entityUncrouch: (entity: Entity) => void
85
- entityEquip: (entity: Entity) => void
86
- entitySleep: (entity: Entity) => void
87
- entitySpawn: (entity: Entity) => void
88
- itemDrop: (entity: Entity) => void
89
- playerCollect: (collector: Entity, collected: Entity) => void
90
- entityAttributes: (entity: Entity) => void
91
- entityGone: (entity: Entity) => void
92
- entityMoved: (entity: Entity) => void
93
- entityDetach: (entity: Entity, vehicle: Entity) => void
94
- entityAttach: (entity: Entity, vehicle: Entity) => void
95
- entityUpdate: (entity: Entity) => void
96
- entityEffect: (entity: Entity, effect: Effect) => void
97
- entityEffectEnd: (entity: Entity, effect: Effect) => void
98
- playerJoined: (player: Player) => void
99
- playerUpdated: (player: Player) => void
100
- playerLeft: (entity: Player) => void
101
- blockUpdate: (oldBlock: Block | null, newBlock: Block) => void
102
- 'blockUpdate:(x, y, z)': (oldBlock: Block | null, newBlock: Block) => void
103
- chunkColumnLoad: (entity: Vec3) => void
104
- chunkColumnUnload: (entity: Vec3) => void
56
+ ) => Promise<void> | void
57
+ actionBar: (jsonMsg: ChatMessage) => Promise<void> | void
58
+ error: (err: Error) => Promise<void> | void
59
+ message: (jsonMsg: ChatMessage, position: string) => Promise<void> | void
60
+ messagestr: (message: string, position: string, jsonMsg: ChatMessage) => Promise<void> | void
61
+ unmatchedMessage: (stringMsg: string, jsonMsg: ChatMessage) => Promise<void> | void
62
+ inject_allowed: () => Promise<void> | void
63
+ login: () => Promise<void> | void
64
+ spawn: () => Promise<void> | void
65
+ respawn: () => Promise<void> | void
66
+ game: () => Promise<void> | void
67
+ title: (text: string) => Promise<void> | void
68
+ rain: () => Promise<void> | void
69
+ time: () => Promise<void> | void
70
+ kicked: (reason: string, loggedIn: boolean) => Promise<void> | void
71
+ end: (reason: string) => Promise<void> | void
72
+ spawnReset: () => Promise<void> | void
73
+ death: () => Promise<void> | void
74
+ health: () => Promise<void> | void
75
+ breath: () => Promise<void> | void
76
+ entitySwingArm: (entity: Entity) => Promise<void> | void
77
+ entityHurt: (entity: Entity) => Promise<void> | void
78
+ entityDead: (entity: Entity) => Promise<void> | void
79
+ entityTaming: (entity: Entity) => Promise<void> | void
80
+ entityTamed: (entity: Entity) => Promise<void> | void
81
+ entityShakingOffWater: (entity: Entity) => Promise<void> | void
82
+ entityEatingGrass: (entity: Entity) => Promise<void> | void
83
+ entityWake: (entity: Entity) => Promise<void> | void
84
+ entityEat: (entity: Entity) => Promise<void> | void
85
+ entityCriticalEffect: (entity: Entity) => Promise<void> | void
86
+ entityMagicCriticalEffect: (entity: Entity) => Promise<void> | void
87
+ entityCrouch: (entity: Entity) => Promise<void> | void
88
+ entityUncrouch: (entity: Entity) => Promise<void> | void
89
+ entityEquip: (entity: Entity) => Promise<void> | void
90
+ entitySleep: (entity: Entity) => Promise<void> | void
91
+ entitySpawn: (entity: Entity) => Promise<void> | void
92
+ itemDrop: (entity: Entity) => Promise<void> | void
93
+ playerCollect: (collector: Entity, collected: Entity) => Promise<void> | void
94
+ entityAttributes: (entity: Entity) => Promise<void> | void
95
+ entityGone: (entity: Entity) => Promise<void> | void
96
+ entityMoved: (entity: Entity) => Promise<void> | void
97
+ entityDetach: (entity: Entity, vehicle: Entity) => Promise<void> | void
98
+ entityAttach: (entity: Entity, vehicle: Entity) => Promise<void> | void
99
+ entityUpdate: (entity: Entity) => Promise<void> | void
100
+ entityEffect: (entity: Entity, effect: Effect) => Promise<void> | void
101
+ entityEffectEnd: (entity: Entity, effect: Effect) => Promise<void> | void
102
+ playerJoined: (player: Player) => Promise<void> | void
103
+ playerUpdated: (player: Player) => Promise<void> | void
104
+ playerLeft: (entity: Player) => Promise<void> | void
105
+ blockUpdate: (oldBlock: Block | null, newBlock: Block) => Promise<void> | void
106
+ 'blockUpdate:(x, y, z)': (oldBlock: Block | null, newBlock: Block) => Promise<void> | void
107
+ chunkColumnLoad: (entity: Vec3) => Promise<void> | void
108
+ chunkColumnUnload: (entity: Vec3) => Promise<void> | void
105
109
  soundEffectHeard: (
106
110
  soundName: string,
107
111
  position: Vec3,
108
112
  volume: number,
109
113
  pitch: number
110
- ) => void
114
+ ) => Promise<void> | void
111
115
  hardcodedSoundEffectHeard: (
112
116
  soundId: number,
113
117
  soundCategory: number,
114
118
  position: Vec3,
115
119
  volume: number,
116
120
  pitch: number
117
- ) => void
118
- noteHeard: (block: Block, instrument: Instrument, pitch: number) => void
119
- pistonMove: (block: Block, isPulling: number, direction: number) => void
120
- chestLidMove: (block: Block, isOpen: number) => void
121
- blockBreakProgressObserved: (block: Block, destroyStage: number) => void
122
- blockBreakProgressEnd: (block: Block) => void
123
- diggingCompleted: (block: Block) => void
124
- diggingAborted: (block: Block) => void
125
- move: () => void
126
- forcedMove: () => void
127
- mount: () => void
128
- dismount: (vehicle: Entity) => void
129
- windowOpen: (vehicle: Window) => void
130
- windowClose: (vehicle: Window) => void
131
- sleep: () => void
132
- wake: () => void
133
- experience: () => void
134
- physicsTick: () => void
135
- physicTick: () => void
136
- scoreboardCreated: (scoreboard: ScoreBoard) => void
137
- scoreboardDeleted: (scoreboard: ScoreBoard) => void
138
- scoreboardTitleChanged: (scoreboard: ScoreBoard) => void
139
- scoreUpdated: (scoreboard: ScoreBoard, item: number) => void
140
- scoreRemoved: (scoreboard: ScoreBoard, item: number) => void
141
- scoreboardPosition: (position: DisplaySlot, scoreboard: ScoreBoard) => void
142
- teamCreated: (team: Team) => void
143
- teamRemoved: (team: Team) => void
144
- teamUpdated: (team: Team) => void
145
- teamMemberAdded: (team: Team) => void
146
- teamMemberRemoved: (team: Team) => void
147
- bossBarCreated: (bossBar: BossBar) => void
148
- bossBarDeleted: (bossBar: BossBar) => void
149
- bossBarUpdated: (bossBar: BossBar) => void
150
- resourcePack: (url: string, hash: string) => void
121
+ ) => Promise<void> | void
122
+ noteHeard: (block: Block, instrument: Instrument, pitch: number) => Promise<void> | void
123
+ pistonMove: (block: Block, isPulling: number, direction: number) => Promise<void> | void
124
+ chestLidMove: (block: Block, isOpen: number) => Promise<void> | void
125
+ blockBreakProgressObserved: (block: Block, destroyStage: number) => Promise<void> | void
126
+ blockBreakProgressEnd: (block: Block) => Promise<void> | void
127
+ diggingCompleted: (block: Block) => Promise<void> | void
128
+ diggingAborted: (block: Block) => Promise<void> | void
129
+ move: () => Promise<void> | void
130
+ forcedMove: () => Promise<void> | void
131
+ mount: () => Promise<void> | void
132
+ dismount: (vehicle: Entity) => Promise<void> | void
133
+ windowOpen: (window: Window) => Promise<void> | void
134
+ windowClose: (window: Window) => Promise<void> | void
135
+ sleep: () => Promise<void> | void
136
+ wake: () => Promise<void> | void
137
+ experience: () => Promise<void> | void
138
+ physicsTick: () => Promise<void> | void
139
+ physicTick: () => Promise<void> | void
140
+ scoreboardCreated: (scoreboard: ScoreBoard) => Promise<void> | void
141
+ scoreboardDeleted: (scoreboard: ScoreBoard) => Promise<void> | void
142
+ scoreboardTitleChanged: (scoreboard: ScoreBoard) => Promise<void> | void
143
+ scoreUpdated: (scoreboard: ScoreBoard, item: number) => Promise<void> | void
144
+ scoreRemoved: (scoreboard: ScoreBoard, item: number) => Promise<void> | void
145
+ scoreboardPosition: (position: DisplaySlot, scoreboard: ScoreBoard) => Promise<void> | void
146
+ teamCreated: (team: Team) => Promise<void> | void
147
+ teamRemoved: (team: Team) => Promise<void> | void
148
+ teamUpdated: (team: Team) => Promise<void> | void
149
+ teamMemberAdded: (team: Team) => Promise<void> | void
150
+ teamMemberRemoved: (team: Team) => Promise<void> | void
151
+ bossBarDeleted: (bossBar: BossBar) => Promise<void> | void
152
+ bossBarUpdated: (bossBar: BossBar) => Promise<void> | void
153
+ resourcePack: (url: string, hash: string) => Promise<void> | void
151
154
  }
152
155
 
153
156
  export interface Bot extends TypedEmitter<BotEvents> {
@@ -191,13 +194,14 @@ export interface Bot extends TypedEmitter<BotEvents> {
191
194
 
192
195
  supportFeature: (feature: string) => boolean
193
196
 
194
- end: () => void
197
+ end: (reason?: string) => void
195
198
 
196
199
  blockAt: (point: Vec3) => Block | null
197
200
 
198
201
  blockInSight: (maxSteps: number, vectorLength: number) => Block | null
199
202
 
200
203
  blockAtCursor: (maxDistance?: number, matcher?: Function) => Block | null
204
+ blockAtEntityCursor: (entity?: entity, maxDistance?: number, matcher?: Function) => Block | null
201
205
 
202
206
  canSeeBlock: (block: Block) => boolean
203
207
 
@@ -255,6 +259,8 @@ export interface Bot extends TypedEmitter<BotEvents> {
255
259
 
256
260
  clearControlStates: () => void
257
261
 
262
+ getExplosionDamages: (targetEntity: Entity, position: Vec3, radius: number, rawDamages?: boolean) => number | null
263
+
258
264
  lookAt: (point: Vec3, force?: boolean, callback?: () => void) => Promise<void>
259
265
 
260
266
  look: (
@@ -302,9 +308,9 @@ export interface Bot extends TypedEmitter<BotEvents> {
302
308
 
303
309
  activateEntityAt: (block: Entity, position: Vec3, callback?: (err?: Error) => void) => Promise<void>
304
310
 
305
- consume: (callback: (err?: Error) => void) => Promise<void>
311
+ consume: (callback?: (err?: Error) => void) => Promise<void>
306
312
 
307
- fish: (callback: (err?: Error) => void) => Promise<void>
313
+ fish: (callback?: (err?: Error) => void) => Promise<void>
308
314
 
309
315
  activateItem: (offhand?: boolean) => void
310
316
 
@@ -337,19 +343,19 @@ export interface Bot extends TypedEmitter<BotEvents> {
337
343
  callback?: (err?: Error) => void
338
344
  ) => Promise<void>
339
345
 
340
- openChest: (chest: Block | Entity) => Chest
346
+ openChest: (chest: Block | Entity) => Promise<Chest>
341
347
 
342
- openFurnace: (furnace: Block) => Furnace
348
+ openFurnace: (furnace: Block) => Promise<Furnace>
343
349
 
344
- openDispenser: (dispenser: Block) => Dispenser
350
+ openDispenser: (dispenser: Block) => Promise<Dispenser>
345
351
 
346
- openEnchantmentTable: (enchantmentTable: Block) => EnchantmentTable
352
+ openEnchantmentTable: (enchantmentTable: Block) => Promise<EnchantmentTable>
347
353
 
348
- openAnvil: (anvil: Block) => Anvil
354
+ openAnvil: (anvil: Block) => Promise<Anvil>
349
355
 
350
356
  openVillager: (
351
357
  villager: Entity
352
- ) => Villager
358
+ ) => Promise<Villager>
353
359
 
354
360
  trade: (
355
361
  villagerInstance: Villager,
@@ -381,9 +387,9 @@ export interface Bot extends TypedEmitter<BotEvents> {
381
387
 
382
388
  transfer: (options: TransferOptions, cb?: (err?: Error) => void) => Promise<void>
383
389
 
384
- openBlock: (block: Block, Class: new () => EventEmitter) => void
390
+ openBlock: (block: Block, Class: new () => EventEmitter) => Promise<void>
385
391
 
386
- openEntity: (block: Entity, Class: new () => EventEmitter) => void
392
+ openEntity: (block: Entity, Class: new () => EventEmitter) => Promise<void>
387
393
 
388
394
  moveSlotItem: (
389
395
  sourceSlot: number,
@@ -454,38 +460,6 @@ export interface Player {
454
460
  entity: Entity
455
461
  }
456
462
 
457
- export class ChatMessage {
458
- json: object
459
- text?: string
460
- translate?: string
461
- with?: ChatMessage[]
462
- extra?: ChatMessage[]
463
- bold: boolean
464
- italic: boolean
465
- underlined: boolean
466
- strikethrough: boolean
467
- obfuscated: boolean
468
- color: string
469
- clickEvent: object
470
- hoverEvent: object
471
-
472
- constructor (message: ChatMessage);
473
-
474
- parse (): void;
475
-
476
- length (): number;
477
-
478
- getText (idx: number, lang?: { [key: string]: string }): string;
479
-
480
- toString (lang?: { [key: string]: string }): string;
481
-
482
- valueOf (): string;
483
-
484
- toMotd (lang?: { [key: string]: string }): string;
485
-
486
- toAnsi (lang?: { [key: string]: string }): string;
487
- }
488
-
489
463
  export interface ChatPattern {
490
464
  pattern: RegExp
491
465
  type: string
@@ -859,7 +833,7 @@ export class BossBar {
859
833
  );
860
834
  }
861
835
 
862
- export var supportedVersions: string[]
863
- export var testedVersions: string[]
836
+ export let supportedVersions: string[]
837
+ export let testedVersions: string[]
864
838
 
865
839
  export function supportFeature (feature: string, version: string): boolean
@@ -1,4 +1,4 @@
1
- const Vec3 = require('vec3').Vec3
1
+ const { Vec3 } = require('vec3')
2
2
  const math = require('./math')
3
3
  const euclideanMod = math.euclideanMod
4
4
  const PI = Math.PI
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.16.5"]
10
+ "versions": ["1.13", "1.17.1"]
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.16.5"]
20
+ "versions": ["1.13", "1.17.1"]
21
21
  },
22
22
  {
23
23
  "name": "creativeSleepNearMobs",
24
24
  "description": "can sleep near mobs in creative",
25
- "versions": ["1.13", "1.16.5"]
25
+ "versions": ["1.13", "1.17.1"]
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.16.5"]
35
+ "versions": ["1.9", "1.17.1"]
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.16.5"]
45
+ "versions": ["1.9", "1.17.1"]
46
46
  },
47
47
  {
48
48
  "name": "customChannelMCPrefixed",
@@ -50,9 +50,14 @@
50
50
  "versions": ["1.8", "1.12.2"]
51
51
  },
52
52
  {
53
- "name": "customChannelNotPrefixed",
54
- "description": "custom channel don't have a prefix",
55
- "versions": ["1.13", "1.16.5"]
53
+ "name": "customChannelIdentifier",
54
+ "description": "custom channel is an identifier starting in minecraft namespace",
55
+ "versions": ["1.13", "1.17.1"]
56
+ },
57
+ {
58
+ "name": "dimensionDataIsAvailable",
59
+ "description": "dimensionData is available, providing an additional information about the current dimension",
60
+ "versions": ["1.17", "1.17.1"]
56
61
  },
57
62
  {
58
63
  "name": "useItemWithBlockPlace",
@@ -62,7 +67,7 @@
62
67
  {
63
68
  "name": "useItemWithOwnPacket",
64
69
  "description": "use item is done with its own packet",
65
- "versions": ["1.9", "1.16.5"]
70
+ "versions": ["1.9", "1.17.1"]
66
71
  },
67
72
  {
68
73
  "name": "blockPlaceHasHeldItem",
@@ -82,7 +87,7 @@
82
87
  {
83
88
  "name": "blockPlaceHasInsideBlock",
84
89
  "description": "block_place packet has inside block",
85
- "versions": ["1.14", "1.16.5"]
90
+ "versions": ["1.14", "1.17.1"]
86
91
  },
87
92
  {
88
93
  "name": "teleportUsesPositionPacket",
@@ -97,7 +102,7 @@
97
102
  {
98
103
  "name": "teleportUsesOwnPacket",
99
104
  "description": "teleport is done using its own packet",
100
- "versions": ["1.9", "1.16.5"]
105
+ "versions": ["1.9", "1.17.1"]
101
106
  },
102
107
  {
103
108
  "name": "oneBlockForSeveralVariations",
@@ -107,7 +112,7 @@
107
112
  {
108
113
  "name": "blockSchemeIsFlat",
109
114
  "description": "all variations of a packet have their own id",
110
- "versions": ["1.13", "1.16.5"]
115
+ "versions": ["1.13", "1.17.1"]
111
116
  },
112
117
  {
113
118
  "name": "tabCompleteHasNoToolTip",
@@ -117,17 +122,17 @@
117
122
  {
118
123
  "name": "tabCompleteHasAToolTip",
119
124
  "description": "tab complete has a tool tip",
120
- "versions": ["1.13", "1.16.5"]
125
+ "versions": ["1.13", "1.17.1"]
121
126
  },
122
127
  {
123
128
  "name": "effectAreMinecraftPrefixed",
124
- "description": "effect are not prefixed",
129
+ "description": "effect are prefixed by minecraft:",
125
130
  "versions": ["1.8", "1.12.2"]
126
131
  },
127
132
  {
128
133
  "name": "effectAreNotPrefixed",
129
- "description": "effect are prefixed by minecraft:",
130
- "versions": ["1.13", "1.16.5"]
134
+ "description": "effect are not prefixed",
135
+ "versions": ["1.13", "1.17.1"]
131
136
  },
132
137
  {
133
138
  "name": "itemsAreAlsoBlocks",
@@ -137,12 +142,12 @@
137
142
  {
138
143
  "name": "itemsAreNotBlocks",
139
144
  "description": "items are not block",
140
- "versions": ["1.13", "1.16.5"]
145
+ "versions": ["1.13", "1.17.1"]
141
146
  },
142
147
  {
143
148
  "name": "fishingBobberCorrectlyNamed",
144
149
  "description": "the fishing hook entity is named fishing_bobber",
145
- "versions": ["1.14", "1.16.5"]
150
+ "versions": ["1.14", "1.17.1"]
146
151
  },
147
152
  {
148
153
  "name": "editBookIsPluginChannel",
@@ -152,7 +157,7 @@
152
157
  {
153
158
  "name": "hasEditBookPacket",
154
159
  "description": "book editing is handled through a packet",
155
- "versions": ["1.13", "1.16.5"]
160
+ "versions": ["1.13", "1.17.1"]
156
161
  },
157
162
  {
158
163
  "name": "clientUpdateBookIdWhenSign",
@@ -192,7 +197,12 @@
192
197
  {
193
198
  "name": "dimensionIsAWorld",
194
199
  "description": "description is a world name (string)",
195
- "versions": ["1.16.2", "1.16.5"]
200
+ "versions": ["1.16.2", "1.17.1"]
201
+ },
202
+ {
203
+ "name": "dimensionDataIsAvailable",
204
+ "description": "dimensionData is available, describing additional dimension information",
205
+ "versions": ["1.17", "1.17.1"]
196
206
  },
197
207
  {
198
208
  "name": "doesntHaveChestType",
@@ -217,22 +227,22 @@
217
227
  {
218
228
  "name": "hasAttackCooldown",
219
229
  "description": "if there is a cooldown after attacks to deal full damage",
220
- "versions": ["1.9", "1.16.5"]
230
+ "versions": ["1.9", "1.17.1"]
221
231
  },
222
232
  {
223
233
  "name": "usesLoginPacket",
224
234
  "description": "uses the login packet as defined in mcData",
225
- "versions": ["1.16", "1.16.5"]
235
+ "versions": ["1.16", "1.17.1"]
226
236
  },
227
237
  {
228
238
  "name": "usesMultiblockSingleLong",
229
239
  "description": "in the multi_block_change packet is stored as a single number",
230
- "versions": ["1.16.2", "1.16.5"]
240
+ "versions": ["1.16.2", "1.17.1"]
231
241
  },
232
242
  {
233
243
  "name": "usesMultiblock3DChunkCoords",
234
244
  "description": "in the multi_block_change packet, all 3 axis coords are defined",
235
- "versions": ["1.16.2", "1.16.5"]
245
+ "versions": ["1.16.2", "1.17.1"]
236
246
  },
237
247
  {
238
248
  "name": "setBlockUsesMetadataNumber",
@@ -247,7 +257,7 @@
247
257
  {
248
258
  "name": "selectingTradeMovesItems",
249
259
  "description": "selecting a trade automatically puts the required items into trading slots",
250
- "versions": ["1.14", "1.16.5"]
260
+ "versions": ["1.14", "1.17.1"]
251
261
  },
252
262
  {
253
263
  "name": "resourcePackUsesHash",
@@ -262,7 +272,7 @@
262
272
  {
263
273
  "name": "teamUsesChatComponents",
264
274
  "description": "teams use chatcomponents for formatting",
265
- "versions": ["1.13", "1.16.5"]
275
+ "versions": ["1.13", "1.17.1"]
266
276
  },
267
277
  {
268
278
  "name": "teamUsesScoreboard",
@@ -277,7 +287,7 @@
277
287
  {
278
288
  "name": "enderCrystalNameNoCapsWithUnderscore",
279
289
  "description": "this is when the end_crystal's entity name is end_crystal",
280
- "versions": ["1.14", "1.16.5"]
290
+ "versions": ["1.14", "1.17.1"]
281
291
  },
282
292
  {
283
293
  "name": "entityNameUpperCaseNoUnderscore",
@@ -288,5 +298,25 @@
288
298
  "name": "entityNameLowerCaseNoUnderscore",
289
299
  "description": "this is when some entity names are lowercase and appended without underscores like 'armorstand' or 'endercrystal'",
290
300
  "versions": ["1.13", "1.13.2"]
301
+ },
302
+ {
303
+ "name": "transactionPacketExists",
304
+ "description": "this is when the description packet existed",
305
+ "versions": ["1.8", "1.16.5"]
306
+ },
307
+ {
308
+ "name": "stateIdUsed",
309
+ "description": "starting in 1.17.1, actionId has been replaced with stateId",
310
+ "versions": ["1.17.1", "1.17.1"]
311
+ },
312
+ {
313
+ "name": "actionIdUsed",
314
+ "description": "pre 1.17, actionId is used",
315
+ "versions": ["1.8", "1.16.5"]
316
+ },
317
+ {
318
+ "name": "setSlotAsTransaction",
319
+ "description": "use setslot as transaction instead of just hoping it'll work",
320
+ "versions": ["1.17", "1.17.1"]
291
321
  }
292
322
  ]
package/lib/loader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const mc = require('minecraft-protocol')
2
- const EventEmitter = require('events').EventEmitter
2
+ const { EventEmitter } = require('events')
3
3
  const pluginLoader = require('./plugin_loader')
4
4
  const supportFeature = require('./supportFeature')
5
5
  const plugins = {
@@ -67,9 +67,10 @@ function createBot (options = {}) {
67
67
  options.logErrors = options.logErrors ?? true
68
68
  options.loadInternalPlugins = options.loadInternalPlugins ?? true
69
69
  options.client = options.client ?? null
70
+ options.brand = options.brand ?? 'vanilla'
70
71
  const bot = new EventEmitter()
71
72
  bot._client = options.client
72
- bot.end = () => bot._client.end()
73
+ bot.end = (reason) => bot._client.end(reason)
73
74
  if (options.logErrors) {
74
75
  bot.on('error', err => {
75
76
  if (!options.hideErrors) {
@@ -98,8 +99,8 @@ function createBot (options = {}) {
98
99
  bot._client.on('error', (err) => {
99
100
  bot.emit('error', err)
100
101
  })
101
- bot._client.on('end', () => {
102
- bot.emit('end')
102
+ bot._client.on('end', (reason) => {
103
+ bot.emit('end', reason)
103
104
  })
104
105
  if (!bot._client.wait_connect) next()
105
106
  else bot._client.once('connect_allowed', next)
@@ -1,4 +1,4 @@
1
- const Vec3 = require('vec3').Vec3
1
+ const { Vec3 } = require('vec3')
2
2
  const { callbackify } = require('../promise_utils')
3
3
 
4
4
  module.exports = inject
@@ -1,4 +1,4 @@
1
- const Vec3 = require('vec3').Vec3
1
+ const { Vec3 } = require('vec3')
2
2
 
3
3
  module.exports = inject
4
4
 
@@ -19,6 +19,9 @@ const FACING_MAP = {
19
19
  function inject (bot, { version }) {
20
20
  const { instruments, blocks } = require('minecraft-data')(version)
21
21
 
22
+ // Stores how many players have currently open a container at a certain position
23
+ const openCountByPos = {}
24
+
22
25
  function parseChestMetadata (chestBlock) {
23
26
  const chestTypes = ['single', 'right', 'left']
24
27
 
@@ -68,18 +71,27 @@ function inject (bot, { version }) {
68
71
  } else if (blockName === 'sticky_piston' || blockName === 'piston') {
69
72
  bot.emit('pistonMove', block, packet.byte1, packet.byte2)
70
73
  } else {
74
+ let block2 = null
75
+
71
76
  if (blockName === 'chest' || blockName === 'trapped_chest') {
72
77
  const chestType = getChestType(block)
73
- if (chestType === 'single') { // Omit left so 'chestLidMove' doesn't emit twice when it's a double chest
74
- bot.emit('chestLidMove', block, packet.byte2, null)
75
- } else if (chestType === 'right') {
78
+ if (chestType === 'right') {
76
79
  const index = Object.values(FACING_MAP[parseChestMetadata(block).facing]).indexOf('left')
77
80
  const cardinalBlock2 = Object.keys(FACING_MAP[parseChestMetadata(block).facing])[index]
78
81
  const block2Position = block.position.plus(CARDINALS[cardinalBlock2])
79
- bot.emit('chestLidMove', block, packet.byte2, bot.blockAt(block2Position))
82
+ block2 = bot.blockAt(block2Position)
83
+ } else if (chestType === 'left') return // Omit left part of the chest so 'chestLidMove' doesn't emit twice when it's a double chest
84
+ }
85
+
86
+ // Emit 'chestLidMove' only if the number of players with the lid open changes
87
+ if (openCountByPos[block.position] !== packet.byte2) {
88
+ bot.emit('chestLidMove', block, packet.byte2, block2)
89
+
90
+ if (packet.byte2 > 0) {
91
+ openCountByPos[block.position] = packet.byte2
92
+ } else {
93
+ delete openCountByPos[block.position]
80
94
  }
81
- } else {
82
- bot.emit('chestLidMove', block, packet.byte2, null)
83
95
  }
84
96
  }
85
97
  })