minecraft-inventory 0.1.33 → 0.1.35

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.33",
3
+ "version": "0.1.35",
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.33
333
+ INV 0.1.35
334
334
  </a>
335
335
  )}
336
336
 
@@ -195,7 +195,9 @@ export const ItemCanvas = memo(function ItemCanvas({
195
195
 
196
196
  {/* Durability bar — vanilla layout: x=2, y=13 in 16×16 item area */}
197
197
  {hasDurability && (() => {
198
- const mcPx = Math.max(1, Math.round(pixelSize))
198
+ // Derive mcPx from renderSize so the bar always fits the container,
199
+ // even at fractional scales where contentSize ≠ 16 * round(scale).
200
+ const mcPx = Math.max(1, Math.floor(renderSize / 16))
199
201
  const barLeft = 2 * mcPx
200
202
  const bgBottom = mcPx
201
203
  const bgWidth = 13 * mcPx
@@ -351,6 +351,13 @@ export function Slot({
351
351
  [isMobile, disabled, heldItem, sendAction, index, pKeyActive, setPKeyActive, focusedSlot, setFocusedSlot, onClickOverride, cancelLongPress, mobileMenuOpen],
352
352
  )
353
353
 
354
+ const handleMobilePickAll = useCallback(() => {
355
+ setMobileMenuOpen(false)
356
+ setShowTooltip(false)
357
+ setFocusedSlot(index)
358
+ sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
359
+ }, [sendAction, index, setFocusedSlot])
360
+
354
361
  const handleMobilePickHalf = useCallback(() => {
355
362
  setMobileMenuOpen(false)
356
363
  setShowTooltip(false)
@@ -537,6 +544,7 @@ export function Slot({
537
544
  item={item}
538
545
  x={mobileTouchPos.x}
539
546
  y={mobileTouchPos.y}
547
+ onPickAll={handleMobilePickAll}
540
548
  onPickHalf={handleMobilePickHalf}
541
549
  onPickCustom={handleMobilePickCustom}
542
550
  onDropOne={handleMobileDropOne}
@@ -553,6 +561,7 @@ interface MobileSlotMenuProps {
553
561
  item: ItemStack
554
562
  x: number
555
563
  y: number
564
+ onPickAll(): void
556
565
  onPickHalf(): void
557
566
  onPickCustom(): void
558
567
  onDropOne(): void
@@ -560,7 +569,7 @@ interface MobileSlotMenuProps {
560
569
  onClose(): void
561
570
  }
562
571
 
563
- function MobileSlotMenu({ item, x, y, onPickHalf, onPickCustom, onDropOne, onDropAll, onClose }: MobileSlotMenuProps) {
572
+ function MobileSlotMenu({ item, x, y, onPickAll, onPickHalf, onPickCustom, onDropOne, onDropAll, onClose }: MobileSlotMenuProps) {
564
573
  const { scale } = useScale()
565
574
  const menuRef = useRef<HTMLDivElement>(null)
566
575
  const [pos, setPos] = useState({ left: x, top: y })
@@ -605,11 +614,11 @@ function MobileSlotMenu({ item, x, y, onPickHalf, onPickCustom, onDropOne, onDro
605
614
  <div className={styles.mobileMenuTitle}>
606
615
  {item.displayName ?? item.name ?? `Item #${item.type}`} ×{item.count}
607
616
  </div>
617
+ <button className={styles.mobileBtn} {...touchBtn(onPickAll)}>Select All ({item.count})</button>
608
618
  <button className={styles.mobileBtn} {...touchBtn(onPickHalf)}>Pick Half ({Math.ceil(item.count / 2)})</button>
609
619
  <button className={styles.mobileBtn} {...touchBtn(onPickCustom)}>Pick Amount…</button>
610
620
  <button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropOne)}>Drop One</button>
611
621
  <button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropAll)}>Drop All</button>
612
- <button className={styles.mobileBtn} {...touchBtn(onClose)}>Cancel</button>
613
622
  </div>
614
623
  )
615
624
  }
@@ -62,15 +62,15 @@ function gridSlots(
62
62
  return slots
63
63
  }
64
64
 
65
- // Slot positions within gui/widgets hotbar texture — matches layouts.mjs Hotbar:
66
- // itemgrid at x: 3, y: 4, margin: 4, width: 9 (20px per slot: 16+4)
65
+ // Slot positions within gui/widgets hotbar texture — matches vanilla Gui.java:
66
+ // item area at x: 3, y: 3, 20px per slot (16 item + 4 border/separator)
67
67
  const HUD_SLOT_STEP = 20
68
68
  function hudHotbarSlots(): RawSlot[] {
69
69
  return Array.from({ length: 9 }, (_, col) => ({
70
70
  // First slot carries explicit index: 36 so the running counter starts there
71
71
  ...(col === 0 ? { index: 36 } : {}),
72
- x: 3.2 + col * HUD_SLOT_STEP,
73
- y: 3.2,
72
+ x: 3 + col * HUD_SLOT_STEP,
73
+ y: 3,
74
74
  group: 'hotbar',
75
75
  }))
76
76
  }