PrismarineJS / prismarine-web-client

Minecraft web client running in your browser
https://prismarinejs.github.io/prismarine-web-client/
MIT License
444 stars 144 forks source link

Hotbar not working client-side until after dying (Bug) #311

Open RepeatGitHub opened 2 years ago

RepeatGitHub commented 2 years ago

I've been playing on Chrome, and noticed something odd; the hotbar is showing question marks, and I can't switch slots. It could be only because it's on Chrome browser, or just my potato computer, since I don't think too many others are encountering this bug.

RepeatGitHub commented 2 years ago

Here's a screenshot of what it looks like. Screenshot 2022-06-15 11 03 56 AM

MilkCafeGo commented 2 years ago

I encounter this too

MilkCafeGo commented 2 years ago

on a chromebook

kf106 commented 2 years ago

The reason for this is because hotbar.init is in a spawn block within hud.js:

link to relevant line

The index.js has a bot.once('spawn') which initializes hud. Perhaps this worked before because the spawn was caught again in time in hud. It isn't now, and the whole bot.on('spawn') in hud.js is only catching the second spawn. Hence the hotbar doesn't work the first time around, but once you die and spawn again, it does.

Moving hotbar.init() up to, say, line 250 just under chat.init() makes it work first spawn as well.