-
Notifications
You must be signed in to change notification settings - Fork 192
NEW REWORKED inventory GUI : Spread, Anvil, Enchant and more! #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
daf4709
c105fd3
c8da2a1
e6b46e1
59bce8f
87805dc
12a6b73
b5a1061
4a04ca5
f219eae
6a28003
0acb7c6
edfa917
a6e1edc
d77b270
ebfe169
78c608e
8612dcb
1cceaf8
26d0dbd
ab29c5d
83e7474
473d672
5cab51b
2b5f46a
a8b8481
e04a9f8
f20a780
5c6c4d4
5ead17a
690027e
db923c5
6323783
62aad92
4ed11b5
f94d944
3ef6ed8
0923e52
1343148
fa34c25
0364c90
6b0e195
b6b0a17
ac0ee83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { TextureProvider, ScaleProvider, InventoryProvider, InventoryOverlay, createMineflayerConnector, MineflayerBot, InventoryOverlayProps } from 'minecraft-inventory/src' | ||
| import { useMemo } from 'react' | ||
| import { proxy, useSnapshot } from 'valtio' | ||
| import { localTexturesConfig } from 'minecraft-inventory/src/generated/localTextures' | ||
| import { useAppScale } from '../../scaleInterface' | ||
|
|
||
| export const openInventoryProxy = proxy({ | ||
| inventory: undefined as InventoryOverlayProps | undefined, | ||
| }) | ||
|
|
||
| export const Inventory = () => { | ||
| const windowType = 'player' | ||
| const connector = useMemo(() => createMineflayerConnector(bot as MineflayerBot), [bot]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against The global Additionally, 🛡️ Proposed fix for null safety export const Inventory = () => {
const windowType = 'player'
+ const { inventory } = useSnapshot(openInventoryProxy) as typeof openInventoryProxy
+
+ // Early return before creating connector if no bot or inventory
+ if (!inventory || !bot) return null
+
const connector = useMemo(() => createMineflayerConnector(bot as MineflayerBot), [bot])
const appScale = useAppScale()
- const { inventory } = useSnapshot(openInventoryProxy) as typeof openInventoryProxy
-
- if (!inventory) return nullNote: The 🤖 Prompt for AI Agents |
||
| const appScale = useAppScale() | ||
| const { inventory } = useSnapshot(openInventoryProxy) as typeof openInventoryProxy | ||
|
|
||
| if (!inventory) return null | ||
|
|
||
| return <div style={{ | ||
| position: 'fixed', | ||
| inset: 0, | ||
| width: '100%', | ||
| height: '100dvh', | ||
| zIndex: 1000, | ||
| }}> | ||
| <TextureProvider config={localTexturesConfig}> | ||
| <ScaleProvider scale={appScale}> | ||
| <InventoryProvider connector={connector}> | ||
| <InventoryOverlay | ||
| showJEI | ||
| enableNotes | ||
| {...inventory} | ||
| /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| </InventoryProvider> | ||
| </ScaleProvider> | ||
| </TextureProvider> | ||
| </div> | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.