minecraft-inventory 0.1.35 → 0.1.36
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
|
@@ -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,
|
|
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
|
}
|