minecraft-inventory 0.1.41 → 0.1.42
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/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A flexible, scalable React library for rendering Minecraft inventory GUIs. Desig
|
|
|
10
10
|
- Tooltips that follow the cursor, matching the original Minecraft style
|
|
11
11
|
- Full keyboard support: number keys (1-9) to swap hotbar, Q to drop, double-click to collect, scroll wheel to pick/place
|
|
12
12
|
- Mobile support: tap-to-focus inventory interactions plus long-press slot actions (pick half / custom amount / drop one / drop all)
|
|
13
|
-
- Optional JEI (item browser) panel on
|
|
13
|
+
- Optional JEI (item browser) panel on right
|
|
14
14
|
- Bot connector layer — plugs into a mineflayer bot or any custom server connection
|
|
15
15
|
- Demo connector with action logging for local development
|
|
16
16
|
- Extendable registry — add new inventory types in one place
|
package/package.json
CHANGED
|
@@ -6,6 +6,14 @@ import { useScale } from '../../context/ScaleContext'
|
|
|
6
6
|
import { useTextures } from '../../context/TextureContext'
|
|
7
7
|
import { getInventoryType } from '../../registry'
|
|
8
8
|
|
|
9
|
+
function isTypingTarget(target: EventTarget | null): boolean {
|
|
10
|
+
if (!target || !(target instanceof HTMLElement)) return false
|
|
11
|
+
const tag = target.tagName
|
|
12
|
+
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true
|
|
13
|
+
if (target.isContentEditable) return true
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
interface RecipeInventoryViewProps {
|
|
10
18
|
navStack: RecipeNavFrame[]
|
|
11
19
|
onBack: () => void
|
|
@@ -96,6 +104,7 @@ export function RecipeInventoryView({
|
|
|
96
104
|
useEffect(() => {
|
|
97
105
|
const handler = (e: KeyboardEvent) => {
|
|
98
106
|
if (e.code !== 'KeyR' && e.code !== 'KeyU') return
|
|
107
|
+
if (isTypingTarget(e.target)) return
|
|
99
108
|
const item = hoveredItemRef.current
|
|
100
109
|
if (!item) return
|
|
101
110
|
onPushFrame(item, e.code === 'KeyR' ? 'recipes' : 'usages')
|
|
@@ -104,10 +113,13 @@ export function RecipeInventoryView({
|
|
|
104
113
|
return () => window.removeEventListener('keydown', handler)
|
|
105
114
|
}, [onPushFrame])
|
|
106
115
|
|
|
107
|
-
// Escape = go back one
|
|
116
|
+
// Escape / Backspace = go back one frame (Backspace on root frame closes recipe view)
|
|
108
117
|
useEffect(() => {
|
|
109
118
|
const handler = (e: KeyboardEvent) => {
|
|
110
|
-
if (e.code
|
|
119
|
+
if (e.code !== 'Escape' && e.code !== 'Backspace') return
|
|
120
|
+
if (isTypingTarget(e.target)) return
|
|
121
|
+
onBack()
|
|
122
|
+
if (e.code === 'Backspace') e.preventDefault()
|
|
111
123
|
}
|
|
112
124
|
window.addEventListener('keydown', handler)
|
|
113
125
|
return () => window.removeEventListener('keydown', handler)
|