minecraft-inventory 0.1.30 → 0.1.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-inventory",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "release": {
@@ -330,7 +330,7 @@ export function InventoryOverlay({
330
330
  lineHeight: 1,
331
331
  }}
332
332
  >
333
- INV 0.1.30
333
+ INV 0.1.32
334
334
  </a>
335
335
  )}
336
336
 
@@ -320,8 +320,8 @@ export function createMineflayerConnector(bot: MineflayerBot, options?: Mineflay
320
320
  }
321
321
 
322
322
  const invSlots: SlotState[] = []
323
- // Slots 0–8: crafting/armour leave empty (not accessible from bot.inventory directly)
324
- for (let i = 0; i < 9; i++) invSlots.push({ index: i, item: null })
323
+ // Slots 0–8: crafting result (0), crafting grid (1-4), armor (5-8)
324
+ for (let i = 0; i < 9; i++) invSlots.push({ index: i, item: convert(bot.inventory.slots[i]) })
325
325
  // Slots 9–35: main inventory
326
326
  for (let i = 9; i <= 35; i++) invSlots.push({ index: i, item: readSlot(i) })
327
327
  // Slots 36–44: hotbar
@@ -562,9 +562,9 @@ export function createMineflayerConnector(bot: MineflayerBot, options?: Mineflay
562
562
  slots.push({ index: 53, item: convert(bot.inventory.slots[45]) })
563
563
  } else {
564
564
  // Player inventory window structure (per registry):
565
- // Slots 0-8: Crafting result + grid + armor (not in bot.inventory.slots, leave empty)
565
+ // Slots 0-8: crafting result (0), crafting grid (1-4), armor (5-8)
566
566
  for (let i = 0; i < 9; i++) {
567
- slots.push({ index: i, item: null })
567
+ slots.push({ index: i, item: convert(bot.inventory.slots[i]) })
568
568
  }
569
569
  // Slots 9-35: Player inventory (bot.inventory.slots indices 9-35)
570
570
  for (let i = 9; i <= 35; i++) {
@@ -360,6 +360,27 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
360
360
  setDragRemainder(null)
361
361
  }, [])
362
362
 
363
+ // Global mouseup listener to finalize drag when the button is released outside slot elements.
364
+ // Slot.handleMouseUp calls e.stopPropagation(), so when mouseup lands on a slot the window
365
+ // listener does NOT fire — the two handlers are mutually exclusive.
366
+ useEffect(() => {
367
+ if (!isDragging) return
368
+
369
+ const handleGlobalMouseUp = () => {
370
+ endDrag()
371
+ }
372
+ const handleBlur = () => {
373
+ cancelDrag()
374
+ }
375
+
376
+ window.addEventListener('mouseup', handleGlobalMouseUp)
377
+ window.addEventListener('blur', handleBlur)
378
+ return () => {
379
+ window.removeEventListener('mouseup', handleGlobalMouseUp)
380
+ window.removeEventListener('blur', handleBlur)
381
+ }
382
+ }, [isDragging, endDrag, cancelDrag])
383
+
363
384
  const getSlot = useCallback(
364
385
  (index: number) => {
365
386
  return windowState?.slots.find((s) => s.index === index)