prismarine-proxy icon indicating copy to clipboard operation
prismarine-proxy copied to clipboard

Not functioning as of 1.19.3

Open MyUsernamee opened this issue 2 years ago • 1 comments

When I attempt to use the following code

import { InstantConnectProxy } from 'prismarine-proxy'
const proxy = new InstantConnectProxy({
  loginHandler: (client) => {
    console.log(client.username)
    return {
      username: 'ice',
    };
  },
  clientOptions: {
    host: 'localhost',
    version: '1.19.3'
  },
  serverOptions: {
    version: '1.19.3',
    port: 25566
  }
})

proxy.on('incoming', (data, meta, toClient, toServer) => {
  toClient.write(meta.name, data)
})

proxy.on('outgoing', (data, meta, toClient, toServer) => {
  toServer.write(meta.name, data)
})

I fails with the error

Disconnecting client because error TypeError [ERR_INVALID_ARG_TYPE]: Serialization error for play.toClient : SizeOf error for undefined : The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at Function.byteLength (node:buffer:740:11)
    at Object.string (eval at compile (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:259:12), <anonymous>:45:25)
    at Object.packet_respawn (eval at compile (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:259:12), <anonymous>:2269:27)       
    at eval (eval at compile (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:259:12), <anonymous>:3083:54)
    at packet (eval at compile (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:259:12), <anonymous>:3131:9)
    at CompiledProtodef.sizeOf (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:89:14)
    at e.message (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:96:40)
    at tryCatch (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (C:\Users\dihydromonoxide\Desktop\Node Projects\minecraft-bot\minecraft-bot\node_modules\protodef\src\compiler.js:96:20) {
  code: 'ERR_INVALID_ARG_TYPE',
  field: 'play.toClient'
}

I am using a lan world with the port 25565, this was also tested with a server

MyUsernamee avatar Feb 20 '23 21:02 MyUsernamee

It appears as though this has to do with the respawn packets and commenting out the following lines in instant_connection_proxy.js seems to have fixed it

//toClient.write('respawn', { ...data, dimension })
//toClient.write('respawn', data)

MyUsernamee avatar Feb 20 '23 21:02 MyUsernamee