minecraft-inventory 0.1.40 → 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
|
|
@@ -622,10 +622,6 @@ Each Minecraft window type has a fixed slot layout defined by the server protoco
|
|
|
622
622
|
- [`prismarine-windows`](https://github.com/PrismarineJS/prismarine-windows) for JS slot maps
|
|
623
623
|
- Minecraft source: `net/minecraft/world/inventory/` for the canonical layout
|
|
624
624
|
|
|
625
|
-
### Memory leak note (Tooltip / MessageFormattedString)
|
|
626
|
-
|
|
627
|
-
If opening tooltips increases memory without returning to baseline, see [docs/MEMORY_LEAK_ANALYSIS.md](docs/MEMORY_LEAK_ANALYSIS.md). The likely cause is `filter:blur(2px)` on obfuscated (§k) text creating retained compositor layers.
|
|
628
|
-
|
|
629
625
|
### Connector protocol
|
|
630
626
|
|
|
631
627
|
When implementing a custom connector, actions have these shapes:
|
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)
|