prismarine-windows 2.3.0 → 2.4.3

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/HISTORY.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 2.4.3
2
+ * fixed typescript typings
3
+
4
+ ## 2.4.2
5
+ * Fixed Exporting correctly and better window typings (#49)
6
+
7
+ ### 2.4.1
8
+ * revert avoid emitting references
9
+
10
+ ### 2.4.0
11
+
12
+ * fix bug with emitting null items (@imharvol)
13
+ * add typings to containerType
14
+ * fix slot count for generic 3x3 containers
15
+
1
16
  ### 2.3.0
2
17
 
3
18
  * Click API endpoints returns changedSlots array (@nickelpro)
package/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  import {EventEmitter} from 'events';
5
5
  import {Item} from 'prismarine-item';
6
6
 
7
- declare class Window extends EventEmitter {
7
+ export class Window extends EventEmitter {
8
8
  constructor (id: number, type: number | string, title: string, slotCount: number, inventorySlotsRange: { start: number, end: number }, craftingResultSlot: number, requiresConfirmation: boolean);
9
9
 
10
10
  /**
@@ -106,7 +106,7 @@ declare class Window extends EventEmitter {
106
106
  * @param metadata metadata value that you are looking for. null means unspecified
107
107
  * @param notFull (optional) - if true, means that the returned item should not be at its stackSize
108
108
  */
109
- findContainerItem(itemType: number, metadata: number | null, notFull: boolean)
109
+ findContainerItem(itemType: number, metadata: number | null, notFull: boolean): Item | null
110
110
 
111
111
  /**
112
112
  * Return the id of the first empty slot between start and end
@@ -189,12 +189,12 @@ declare class Window extends EventEmitter {
189
189
  */
190
190
  clear(blockId?: number, count?: number): void;
191
191
  }
192
- declare interface Click {
192
+ export interface Click {
193
193
  mode: number;
194
194
  mouseButton: number;
195
195
  slot: number;
196
196
  }
197
- declare interface WindowInfo {
197
+ export interface WindowInfo {
198
198
  type: number | string;
199
199
  inventory: { start: number, end: number };
200
200
  slots: number;
@@ -202,9 +202,39 @@ declare interface WindowInfo {
202
202
  requireConfirmation: boolean;
203
203
  }
204
204
 
205
- declare interface WindowsExports {
205
+ export interface WindowsExports {
206
206
  createWindow(id: number, type: number | string, title: string, slotCount?: number): Window;
207
207
  Window: typeof Window;
208
- windows: {[key: string]: WindowInfo};
208
+ windows: {[key in WindowName]: WindowInfo};
209
209
  }
210
+
210
211
  export declare function loader(mcVersion: string): WindowsExports;
212
+
213
+ export default loader;
214
+
215
+ export type WindowName =
216
+ 'minecraft:inventory' |
217
+ 'minecraft:generic_9x1' |
218
+ 'minecraft:generic_9x2' |
219
+ 'minecraft:generic_9x3' |
220
+ 'minecraft:generic_9x4' |
221
+ 'minecraft:generic_9x5' |
222
+ 'minecraft:generic_9x6' |
223
+ 'minecraft:generic_3x3' |
224
+ 'minecraft:anvil' |
225
+ 'minecraft:beacon' |
226
+ 'minecraft:blast_furnace' |
227
+ 'minecraft:brewing_stand' |
228
+ 'minecraft:crafting' |
229
+ 'minecraft:enchantment' |
230
+ 'minecraft:furnace' |
231
+ 'minecraft:grindstone' |
232
+ 'minecraft:hopper' |
233
+ 'minecraft:lectern' |
234
+ 'minecraft:loom' |
235
+ 'minecraft:merchant' |
236
+ 'minecraft:shulker_box' |
237
+ 'minecraft:smithing' |
238
+ 'minecraft:smoker' |
239
+ 'minecraft:cartography' |
240
+ 'minecraft:stonecutter'
package/index.js CHANGED
@@ -15,7 +15,7 @@ function loader (mcVersion) {
15
15
  windows['minecraft:generic_9x4'] = { type: protocolId++, inventory: { start: 4 * 9, end: 4 * 9 + 35 }, slots: 4 * 9 + 36, craft: -1, requireConfirmation: true }
16
16
  windows['minecraft:generic_9x5'] = { type: protocolId++, inventory: { start: 5 * 9, end: 5 * 9 + 35 }, slots: 5 * 9 + 36, craft: -1, requireConfirmation: true }
17
17
  windows['minecraft:generic_9x6'] = { type: protocolId++, inventory: { start: 6 * 9, end: 6 * 9 + 35 }, slots: 6 * 9 + 36, craft: -1, requireConfirmation: true }
18
- windows['minecraft:generic_3x3'] = { type: protocolId++, inventory: { start: 7 * 9, end: 7 * 9 + 35 }, slots: 7 * 9 + 36, craft: -1, requireConfirmation: true }
18
+ windows['minecraft:generic_3x3'] = { type: protocolId++, inventory: { start: 3 * 3, end: 3 * 3 + 35 }, slots: 3 * 3 + 36, craft: -1, requireConfirmation: true }
19
19
  windows['minecraft:anvil'] = { type: protocolId++, inventory: { start: 3, end: 38 }, slots: 39, craft: 2, requireConfirmation: true }
20
20
  windows['minecraft:beacon'] = { type: protocolId++, inventory: { start: 1, end: 36 }, slots: 37, craft: -1, requireConfirmation: true }
21
21
  windows['minecraft:blast_furnace'] = { type: protocolId++, inventory: { start: 3, end: 38 }, slots: 39, craft: 2, requireConfirmation: true }
package/lib/Window.js CHANGED
@@ -147,8 +147,9 @@ module.exports = (Item) => {
147
147
  if (newItem) newItem.slot = slot
148
148
  const oldItem = this.slots[slot]
149
149
  this.slots[slot] = newItem
150
- this.emit('updateSlot', slot, { ...oldItem }, { ...newItem })
151
- this.emit(`updateSlot:${slot}`, { ...oldItem }, { ...newItem })
150
+
151
+ this.emit('updateSlot', slot, oldItem, newItem)
152
+ this.emit(`updateSlot:${slot}`, oldItem, newItem)
152
153
  }
153
154
 
154
155
  findItemRange (start, end, itemType, metadata, notFull, nbt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prismarine-windows",
3
- "version": "2.3.0",
3
+ "version": "2.4.3",
4
4
  "description": "Represent minecraft windows",
5
5
  "main": "index.js",
6
6
  "scripts": {