From 598d8dce612d84cee58e7e4cbb0d6d82f1a29ff4 Mon Sep 17 00:00:00 2001 From: Keir Finlow-Bates Date: Sun, 22 May 2022 00:18:42 +0300 Subject: [PATCH] Fix for #301 (#306) Co-authored-by: Keir Finlow-Bates Co-authored-by: Romain Beaumont --- lib/menus/hud.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/menus/hud.js b/lib/menus/hud.js index ccec66e1c..a8cbd1b5e 100644 --- a/lib/menus/hud.js +++ b/lib/menus/hud.js @@ -212,7 +212,7 @@ class Hud extends LitElement { debugMenu.bot = bot chat.init(bot._client, renderer) - playerList.init(bot, host) + bot.on('spawn', () => playerList.init(bot, host)) bot.on('entityHurt', (entity) => { if (entity !== bot.entity) return @@ -251,15 +251,17 @@ class Hud extends LitElement { // breathbar.updateOxygen(bot.oxygenLevel) // }) - this.shadowRoot.querySelector('#xp-bar-bg').style.display = bot.player.gamemode === 1 ? 'none' : 'block' - this.shadowRoot.querySelector('#xp-bar-bg').firstElementChild.style.width = `${182 * bot.experience.progress}px` - xpLabel.innerHTML = bot.experience.level - xpLabel.style.display = bot.experience.level > 0 ? 'block' : 'none' - healthbar.gameModeChanged(bot.player.gamemode, bot.game.hardcore) - healthbar.updateHealth(bot.health) - foodbar.updateHunger(bot.food) - // breathbar.updateOxygen(bot.oxygenLevel ?? 20) - hotbar.init() + bot.on('spawn', () => { + this.shadowRoot.querySelector('#xp-bar-bg').style.display = bot.player.gamemode === 1 ? 'none' : 'block' + this.shadowRoot.querySelector('#xp-bar-bg').firstElementChild.style.width = `${182 * bot.experience.progress}px` + xpLabel.innerHTML = bot.experience.level + xpLabel.style.display = bot.experience.level > 0 ? 'block' : 'none' + healthbar.gameModeChanged(bot.player.gamemode, bot.game.hardcore) + healthbar.updateHealth(bot.health) + foodbar.updateHunger(bot.food) + // breathbar.updateOxygen(bot.oxygenLevel ?? 20) + hotbar.init() + }) if (document.getElementById('options-screen').forceMobileControls || isMobile()) { this.showMobileControls(true)