minecraft-inventory 0.1.35 → 0.1.37

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.35",
3
+ "version": "0.1.37",
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.35
333
+ INV 0.1.37
334
334
  </a>
335
335
  )}
336
336
 
@@ -81,6 +81,7 @@ export function JEI({
81
81
  const { hoveredSlot } = useInventoryContext()
82
82
  const [search, setSearch] = useState('')
83
83
  const [page, setPage] = useState(0)
84
+ const [showAllItems, setShowAllItems] = useState(false)
84
85
  const [showFavorites, setShowFavorites] = useState(false)
85
86
  const [favorites, setFavorites] = useState<Set<string>>(loadFavorites)
86
87
  // Map from negative slot index → JEI item (to enable F-key and R/U on hover)
@@ -187,7 +188,7 @@ export function JEI({
187
188
  }, [items, showFavorites, favorites])
188
189
 
189
190
  const filteredItems = useMemo(() => {
190
- if (!search.trim()) return baseList
191
+ if (!search.trim()) return showAllItems ? baseList : []
191
192
  const q = search.toLowerCase()
192
193
  return baseList.filter(
193
194
  (item) =>
@@ -195,7 +196,7 @@ export function JEI({
195
196
  item.name.toLowerCase().includes(q) ||
196
197
  String(item.type).includes(q),
197
198
  )
198
- }, [baseList, search])
199
+ }, [baseList, search, showAllItems])
199
200
 
200
201
  const totalPages = Math.ceil(filteredItems.length / itemsPerPage)
201
202
  const visibleItems = filteredItems.slice(page * itemsPerPage, (page + 1) * itemsPerPage)
@@ -310,6 +311,16 @@ export function JEI({
310
311
  >
311
312
  <StarIcon size={Math.max(1, Math.round(6 * scale))} />
312
313
  </button>
314
+ {!showAllItems && (
315
+ <button
316
+ className={styles.pageBtn}
317
+ onClick={() => { setShowAllItems(true); setPage(0) }}
318
+ style={{ fontSize: 6 * scale, padding: `${scale}px ${2 * scale}px` }}
319
+ title="Show all items"
320
+ >
321
+ 👁
322
+ </button>
323
+ )}
313
324
  </div>
314
325
  </div>
315
326
 
@@ -54,8 +54,6 @@ export function Slot({
54
54
  setPKeyActive,
55
55
  focusedSlot,
56
56
  setFocusedSlot,
57
- mobilePickAmount,
58
- setMobilePickAmount,
59
57
  dragEndedRef,
60
58
  noPlaceholders,
61
59
  } = useInventoryContext()
@@ -365,28 +363,6 @@ export function Slot({
365
363
  sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
366
364
  }, [sendAction, index, setFocusedSlot])
367
365
 
368
- const handleMobilePickCustom = useCallback(() => {
369
- if (!item) return
370
- const input = window.prompt(`Pick amount (max ${item.count}):`, String(mobilePickAmount))
371
- const amount = parseInt(input ?? '', 10)
372
- if (isNaN(amount) || amount <= 0) return
373
- setMobilePickAmount(amount)
374
- setMobileMenuOpen(false)
375
- setShowTooltip(false)
376
- setFocusedSlot(index)
377
- const take = Math.min(amount, item.count)
378
- if (take >= item.count) {
379
- // Pick all: just left-click
380
- sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
381
- } else {
382
- // Pick up all, then put back (count - take) items one-by-one via right-click
383
- sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
384
- for (let i = 0; i < item.count - take; i++) {
385
- sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
386
- }
387
- }
388
- }, [item, mobilePickAmount, sendAction, index, setFocusedSlot, setMobilePickAmount])
389
-
390
366
  const handleMobileDropOne = useCallback(() => {
391
367
  setMobileMenuOpen(false)
392
368
  setShowTooltip(false)
@@ -546,7 +522,6 @@ export function Slot({
546
522
  y={mobileTouchPos.y}
547
523
  onPickAll={handleMobilePickAll}
548
524
  onPickHalf={handleMobilePickHalf}
549
- onPickCustom={handleMobilePickCustom}
550
525
  onDropOne={handleMobileDropOne}
551
526
  onDropAll={handleMobileDropAll}
552
527
  onClose={closeMobileMenu}
@@ -563,13 +538,12 @@ interface MobileSlotMenuProps {
563
538
  y: number
564
539
  onPickAll(): void
565
540
  onPickHalf(): void
566
- onPickCustom(): void
567
541
  onDropOne(): void
568
542
  onDropAll(): void
569
543
  onClose(): void
570
544
  }
571
545
 
572
- function MobileSlotMenu({ item, x, y, onPickAll, onPickHalf, onPickCustom, onDropOne, onDropAll, onClose }: MobileSlotMenuProps) {
546
+ function MobileSlotMenu({ item, x, y, onPickAll, onPickHalf, onDropOne, onDropAll, onClose }: MobileSlotMenuProps) {
573
547
  const { scale } = useScale()
574
548
  const menuRef = useRef<HTMLDivElement>(null)
575
549
  const [pos, setPos] = useState({ left: x, top: y })
@@ -616,7 +590,6 @@ function MobileSlotMenu({ item, x, y, onPickAll, onPickHalf, onPickCustom, onDro
616
590
  </div>
617
591
  <button className={styles.mobileBtn} {...touchBtn(onPickAll)}>Select All ({item.count})</button>
618
592
  <button className={styles.mobileBtn} {...touchBtn(onPickHalf)}>Pick Half ({Math.ceil(item.count / 2)})</button>
619
- <button className={styles.mobileBtn} {...touchBtn(onPickCustom)}>Pick Amount…</button>
620
593
  <button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropOne)}>Drop One</button>
621
594
  <button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropAll)}>Drop All</button>
622
595
  </div>
@@ -53,9 +53,6 @@ export interface InventoryContextValue {
53
53
  /** Pending first digit for P-key slot number entry */
54
54
  pKeyDigit: string
55
55
  setPKeyDigit: (d: string) => void
56
- /** Last amount entered in the mobile pick-amount prompt */
57
- mobilePickAmount: number
58
- setMobilePickAmount: (amount: number) => void
59
56
  /** Ref set to true when a drag just ended; cleared on next mouseDown.
60
57
  * Used by Slot to suppress spurious click events that fire after endDrag. */
61
58
  dragEndedRef: React.MutableRefObject<boolean>
@@ -102,7 +99,6 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
102
99
  const [pKeyActive, setPKeyActive] = useState(false)
103
100
  const [focusedSlot, setFocusedSlot] = useState<number | null>(null)
104
101
  const [pKeyDigit, setPKeyDigit] = useState('')
105
- const [mobilePickAmount, setMobilePickAmount] = useState(1)
106
102
 
107
103
  const connectorRef = useRef(connector)
108
104
  connectorRef.current = connector
@@ -419,8 +415,6 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
419
415
  setFocusedSlot,
420
416
  pKeyDigit,
421
417
  setPKeyDigit,
422
- mobilePickAmount,
423
- setMobilePickAmount,
424
418
  dragEndedRef,
425
419
  resolveEnchantmentName,
426
420
  }