forked from PrismarineJS/prismarine-web-client
-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
daf4709
inv start!
zardoy c105fd3
local config, make test
zardoy c8da2a1
final changes by me for now
zardoy e6b46e1
fix: resolve cherry-pick conflicts and fix TS errors
59bce8f
feat: rewrite hotbar to React InventoryWindow component
87805dc
feat: integrate player model rendering in inventory
12a6b73
fix: use connector for inventory close and cleanup on unmount
b5a1061
fix: wire hotbarOnly and formatTitle to inventory connectors
4a04ca5
fix: use renderer/viewer renderSlot path after hotbar cherry-picks
zardoy f219eae
lint
zardoy 6a28003
upinv
zardoy 0acb7c6
never use remote fallback
zardoy edfa917
enable notes as was intended
zardoy a6e1edc
use mineflayer fix
zardoy d77b270
up mouse
zardoy ebfe169
Merge remote-tracking branch 'origin/next' into new-inventory
zardoy 78c608e
fix: correct block faces, durability bar and enrich JEI textures
8612dcb
up inv
zardoy 1cceaf8
fix: remove CDN texture fallback, use local atlases only
26d0dbd
feat: enrich recipe item textures from local atlas
ab29c5d
fix: use ImageBitmap atlas for item sprites, keep data URL for block …
83e7474
feat: enable noPlaceholders to hide armor slot labels
473d672
feat: restore JEI item giving in creative mode
5cab51b
refactor: render player model directly inside inventory component
2b5f46a
up inv
zardoy a8b8481
a wa y to disable notes
zardoy e04a9f8
fix: mobile hotbar slot selection and inventory button
f20a780
up inv
zardoy 5c6c4d4
perf: defer JEI mount and cache JEI items for faster inventory open
5ead17a
feat: wire up anvil cost client-side computation
690027e
feat: pass resolveEnchantmentName to inventory provider
db923c5
FINISH player model display perfect not duplicated code
zardoy 6323783
up mouse
zardoy 62aad92
revert mouse upadte & up inv
zardoy 4ed11b5
re-update
zardoy f94d944
add settings!
zardoy 3ef6ed8
feat: wire inventory settings gear button to open options menu
0923e52
Update package.json
zardoy 1343148
fix: hide player model canvas until skin texture is loaded
fa34c25
Update package.json
zardoy 0364c90
IMPORTANT: update jei textures on texture update
zardoy 6b0e195
Merge branch 'next' into new-inventory
zardoy b6b0a17
lint all
zardoy ac0ee83
up mineflayer to use latest Gen's physics changes (fixes physics regr…
zardoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { TextureProvider, ScaleProvider, InventoryProvider, InventoryOverlay, createMineflayerConnector, MineflayerBot, InventoryOverlayProps } from 'minecraft-inventory/src' | ||
| import { useMemo } from 'react' | ||
| import { proxy, useSnapshot } from 'valtio' | ||
| 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]) | ||
| 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, | ||
| // backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
| }}> | ||
| <TextureProvider> | ||
| <ScaleProvider scale={appScale}> | ||
| <InventoryProvider connector={connector}> | ||
| <InventoryOverlay | ||
| showJEI | ||
| {...inventory} | ||
| /> | ||
| </InventoryProvider> | ||
| </ScaleProvider> | ||
| </TextureProvider> | ||
| </div> | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against
botbeing undefined to prevent runtime crash.The global
botvariable can beundefinedduring disconnect or before connection (seesrc/index.tswherebot = undefinedandsrc/globals.jswhere it starts asundefined). CallingcreateMineflayerConnector(bot as MineflayerBot)whenbotis undefined will likely crash.Additionally,
useMemowith[bot]as a dependency may not re-trigger correctly sincebotis a global variable that React doesn't track. When a new bot instance is assigned, this component won't automatically re-render.🛡️ 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
useMemodependency on globalbotmay still not work as expected for re-renders. Consider using a state or context pattern to track the bot instance if reconnection scenarios need to be supported.🤖 Prompt for AI Agents