PrismarineJS / flying-squid

Create Minecraft servers with a powerful, stable, and high level JavaScript API.

Home Page:https://prismarinejs.github.io/flying-squid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Flying squid and Prismarine Web Client incompatibility

kf106 opened this issue · comments

Are there any combinations of flying squid and the prismarine web client that work?

I either get packet serialization errors with the earlier versions, or problems with usernames and client logins with the later ones.

I suggest you report all the precise errors that you're seeing because yes they should be fully compatible
We use mineflayer in flying squid tests so it should work

System details:

$ uname -a
kf106-pc 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Set up flying squid:

$ git clone https://github.com/PrismarineJS/flying-squid.git
$ node -v
v16.14.2
$ npm install
$ node app.js
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for redstone_torch
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for repeater
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for oak_sign
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for spruce_sign
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for birch_sign
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for acacia_sign
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for jungle_sign
May 12th 2022, 11:24:19 [WARN]: onItemPlace handler was registered twice for dark_oak_sign
May 12th 2022, 11:24:19 [INFO]: Server listening on port 20565
May 12th 2022, 11:24:19 [INFO]: World seed: 523543081

This runs flying squid with the default 1.16.1 version as per config/default-configuration.json (except I changed the port to 20565 because I have a server.jar minecraft server running on that port for my kids).

Set up prismarine-web-client:

$ git clone https://github.com/PrismarineJS/prismarine-web-client.git
$ npm install
$ npm start

> prismarine-web-client@1.3.0 start
> node --max-old-space-size=8192 server.js 8080 dev

Server listening on port 8080
assets by path textures/ 71.7 MiB 22183 assets
assets by path blocksStates/*.json 71.8 MiB 13 assets
assets by path extra-textures/ 6.84 MiB 10 assets
assets by path *.js 47.9 MiB 3 assets
assets by path *.json 548 bytes
  asset manifest.json 297 bytes [emitted] [from: assets/manifest.json] [copied]
  + 2 assets
assets by path *.png 3.26 MiB
  asset invsprite.png 3.23 MiB [emitted] [from: assets/invsprite.png] [copied]
  asset favicon.png 28.3 KiB [emitted] [from: assets/favicon.png] [copied]
assets by path *.map 209 KiB
  asset workbox-36b4d269.js.map 204 KiB [emitted]
  asset service-worker.js.map 5.21 KiB [emitted]
+ 8 assets
orphan modules 26.7 KiB [orphan] 6 modules
runtime modules 1.25 KiB 6 modules
javascript modules 6.5 MiB
  modules by path ./node_modules/ 6.4 MiB 712 modules
  modules by path ./lib/ 88.2 KiB
    modules by path ./lib/menus/ 68.9 KiB 17 modules
    modules by path ./lib/*.js 19.3 KiB 5 modules
  optional modules 120 bytes [optional]
    buffer (ignored) 15 bytes [optional] [built] [code generated]
    + 7 modules
  + 6 modules
json modules 47.8 MiB 444 modules

LOG from GenerateSW
<i> The service worker at service-worker.js will precache
<i>         2 URLs, totaling 1.98 kB.

webpack 5.72.1 compiled successfully in 11164 ms

For this I edit config.json to have "defaultHost": "127.0.0.1" and "defaultHostPort": 20565 to save typing in the browser later.

So now I should have a flying squid server on 20565 and a prismarine-web-client running on localhost:8080 both on the same 1.16.1 version.

I go to localhost:8080 in my Brave browser [Version 1.38.111 Chromium: 101.0.4951.54 (Official Build) (64-bit) and it looks promising: there's a splash screen with flying squid, the Mincraft web edition title and "Prismarine is a beautiful block".

I right-click inspect to call up the dev tools, and open the console.

Router is responding to: /
Router is responding to: /manifest.json

I click on the Play button. The details are what I expect: server IP 127.0.0.1, server port 20565, proxy blank, port blank, username kf106, bot version 1.16.1.

I click Connect. Console shows:

connecting to 127.0.0.1 20565 with kf106
User was kicked! {"text":"Failed to verify username!"}

I try with a blank username. Console shows:

createClient.js:22 Uncaught (in promise) AssertionError [ERR_ASSERTION]: username is required
    at Object.createClient (createClient.js:22:1)
    at Object.createBot (loader.js:94:1)
    at connect (index.js:178:1)
    at PlayScreen.<anonymous> (index.js:133:1)
    at PlayScreen.onConnectPress (play_screen.js:151:1)
    at EventPart.handleEvent (lit-html.js:1385:1)
    at Button.onBtnClick (button.js:134:1)
    at EventPart.handleEvent (lit-html.js:1385:1)

So then I reason that perhaps the problem is that it's trying to verify my username and password. So I change the flying-squid configuration to "online-mode": false, and try again with a username of kf106:

The flying squid console shows the rather promising:

May 12th 2022, 11:42:16 [INFO]: kf106 (::ffff:127.0.0.1) connected
May 12th 2022, 11:42:16 [INFO]: Position written, spawning player...
May 12th 2022, 11:42:28 [INFO]: kf106 disconnected

But prismarine-web-client, although initially looking like it is going to connect, shows this in the console:

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)
loader.js:76 Error: Cannot call write after a stream was destroyed
    at new NodeError (errors-browser.js:26:1)
    at doWrite (_stream_writable.js:409:1)
    at writeOrBuffer (_stream_writable.js:398:1)
    at Socket.Writable.write (_stream_writable.js:307:1)
    at Socket.write (browser.js:265:1)
    at Framer.ondata (_stream_readable.js:681:1)
    at Framer.emit (events.js:153:1)
    at addChunk (_stream_readable.js:298:1)
    at readableAddChunk (_stream_readable.js:280:1)
    at Framer.Readable.push (_stream_readable.js:241:1)
index.js:191 Encountered error! Error: Cannot call write after a stream was destroyed
    at new NodeError (errors-browser.js:26:1)
    at doWrite (_stream_writable.js:409:1)
    at writeOrBuffer (_stream_writable.js:398:1)
    at Socket.Writable.write (_stream_writable.js:307:1)
    at Socket.write (browser.js:265:1)
    at Framer.ondata (_stream_readable.js:681:1)
    at Framer.emit (events.js:153:1)
    at addChunk (_stream_readable.js:298:1)
    at readableAddChunk (_stream_readable.js:280:1)
    at Framer.Readable.push (_stream_readable.js:241:1)
index.js:205 disconnected for socketClosed

I'd like to write a tutorial on "how to set up a flying squid server and a prismarine-web-client web page to provide your own Minecraft server and interface to it", but I'm finding it hard to get enough information from the repos to do so.

I'm guessing part of the problem is that I don't know how to set up a list of usernames and passwords in flying squid, and how to enter a password for a username in prismarine-web-client.

Ok thanks for the explanation
There seems to be an issue with the playerlist_overlay.js file in prismarine-web-client

You can try to fix it or report an issue in GitHub and/or discord

Flying squid offline mode is open to all users, there is no validation

https://github.com/PrismarineJS/prismarine-web-client/blob/master/lib/menus/components/playerlist_overlay.js#L106 i figure the problem is this is done too early

Moving that to a listener like bot.on('spawn' would likely this fix issue

Your tutorial idea sounds great, feel free to keep asking questions, here or in discord

Wrapping this.clientId = bot.player.uuid in a bot.on('spawn' ... ) pushes the problem further to this:

Uncaught TypeError: Cannot read properties of undefined (reading 'gamemode')
    at Hud.init (hud.js:254: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)
    at addChunk (_stream_readable.js:298:1)

It seems like there's a deeper workflow problem.

I seem to have it working by wrapping a bunch of stuff in hud.js in prismarine-web-client in a bot.on('spawn' ... ) as you suggested.