Skip to content

Commit 598d8dc

Browse files
kf106moonborrowrom1504
authored
Fix for #301 (#306)
Co-authored-by: Keir Finlow-Bates <[email protected]> Co-authored-by: Romain Beaumont <[email protected]>
1 parent e1df6a1 commit 598d8dc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/menus/hud.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class Hud extends LitElement {
212212
debugMenu.bot = bot
213213

214214
chat.init(bot._client, renderer)
215-
playerList.init(bot, host)
215+
bot.on('spawn', () => playerList.init(bot, host))
216216

217217
bot.on('entityHurt', (entity) => {
218218
if (entity !== bot.entity) return
@@ -251,15 +251,17 @@ class Hud extends LitElement {
251251
// breathbar.updateOxygen(bot.oxygenLevel)
252252
// })
253253

254-
this.shadowRoot.querySelector('#xp-bar-bg').style.display = bot.player.gamemode === 1 ? 'none' : 'block'
255-
this.shadowRoot.querySelector('#xp-bar-bg').firstElementChild.style.width = `${182 * bot.experience.progress}px`
256-
xpLabel.innerHTML = bot.experience.level
257-
xpLabel.style.display = bot.experience.level > 0 ? 'block' : 'none'
258-
healthbar.gameModeChanged(bot.player.gamemode, bot.game.hardcore)
259-
healthbar.updateHealth(bot.health)
260-
foodbar.updateHunger(bot.food)
261-
// breathbar.updateOxygen(bot.oxygenLevel ?? 20)
262-
hotbar.init()
254+
bot.on('spawn', () => {
255+
this.shadowRoot.querySelector('#xp-bar-bg').style.display = bot.player.gamemode === 1 ? 'none' : 'block'
256+
this.shadowRoot.querySelector('#xp-bar-bg').firstElementChild.style.width = `${182 * bot.experience.progress}px`
257+
xpLabel.innerHTML = bot.experience.level
258+
xpLabel.style.display = bot.experience.level > 0 ? 'block' : 'none'
259+
healthbar.gameModeChanged(bot.player.gamemode, bot.game.hardcore)
260+
healthbar.updateHealth(bot.health)
261+
foodbar.updateHunger(bot.food)
262+
// breathbar.updateOxygen(bot.oxygenLevel ?? 20)
263+
hotbar.init()
264+
})
263265

264266
if (document.getElementById('options-screen').forceMobileControls || isMobile()) {
265267
this.showMobileControls(true)

0 commit comments

Comments
 (0)