prismarine-web-client icon indicating copy to clipboard operation
prismarine-web-client copied to clipboard

Can't connect to flying squid server with prismarine-web-client

Open kf106 opened this issue 3 years ago • 2 comments

Please see https://github.com/PrismarineJS/flying-squid/issues/591

There seems to be an issue with the playerlist_overlay.js file in prismarine-web-client when connecting to a flying squid server, in that https://github.com/PrismarineJS/prismarine-web-client/blob/master/lib/menus/components/playerlist_overlay.js#L106 is called too early.

connecting to 127.0.0.1 20565 with kf106
index.js:220 bot spawned - starting viewer
index.js:226 6
viewer.js:34 Using version: 1.16.1
index.js:393 Done!
playerlist_overlay.js:106 Uncaught TypeError: Cannot read properties of undefined (reading 'uuid')
    at PlayerListOverlay.init (playerlist_overlay.js:106:1)
    at Hud.init (hud.js:215:1)
    at EventEmitter.<anonymous> (index.js:395:1)
    at Object.onceWrapper (events.js:242:1)
    at EventEmitter.emit (events.js:158:1)
    at Client.<anonymous> (health.js:13:1)
    at Object.onceWrapper (events.js:243:1)
    at Client.emit (events.js:158:1)
    at FullPacketParser.<anonymous> (client.js:91:1)
    at FullPacketParser.emit (events.js:153:1)

kf106 avatar May 12 '22 09:05 kf106

I have managed to get it working by wrapping a couple of things in hud.js in a bot.on('spawn' ...) but as I've only looked at the code for about an hour, I'm guessing I shouldn't be the one to make the change.

Here are the changes:

line 215 of ./lib/menus/hud.js: bot.on('spawn', () => playerList.init(bot, host))

lines 254-263 of ./lib/menus/hud.js:

    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()
    })

kf106 avatar May 12 '22 10:05 kf106

Having the same issue.

ironon avatar Jul 13 '23 00:07 ironon