Open klochk opened 3 years ago
[!] The FAQ doesn't contain a resolution to my issue
I'm building proxy using minecraft-protocol only. But having 2 troubles. Player everytime kicked with error(without any errors in my proxy process).
And 2nd problem is
var server = utils.createServer(downstream, 1, "My shiny proxy") let client = null server.on("login", (socket) => { var loginPacket = utils.createLoginPacket(server, socket, false, 0, 10); var positionPacket = utils.createPositionPacket(0, 100, 0, 0, 0); socket.write('login', loginPacket); socket.write('position', positionPacket); logger.info('Player ' + socket.username + ' logged in.'); socket.on('packet', (packet, meta) => { logger.downstream('Client => Downstream => Upstream => Server'); utils.emitEvents(socket, meta, packet); }); socket.on('raw', (data, meta) => { if(client === null) { client = utils.createClient(upstream, socket.username); client.on('raw', (data, meta) => { socket.write(meta.name, data); }); client.on('packet', (data, meta) => { logger.upstream('Client <= Downstream <= Upstream <= Server'); utils.emitEvents(client, meta, data); }); } console.log(data) client.write(meta.name, data); }); socket.on("message", (packet, message) => { if(message.startsWith('/')) { logger.data('Player ' + socket.username + ' issued server command: ' + message); } else { logger.data('Player ' + socket.username + ' > ' + message); } }); socket.on('end', (reason) => { logger.info('Player ' + socket.username + ' disconnected: ' + reason); }); });
Everytime, no matter what, player will be kicked.
utils.js ->
var mc = require('minecraft-protocol') function createJsonMessage(client, sender, message) { var msg = { translate: "chat.type.text", "with": [ { "text": sender }, { "text":message } ] }; return msg } function writeJsonMessage(client, sender, message) { var msg = createJsonMessage(sender, message) client.write("chat", { "message": JSON.stringify(msg) }); } function emitEvents(client, meta, packet) { if(meta.name == "chat") { client.emit("message", packet, packet.message); client.emit("proxy_packet", packet.message); } } function createServer(config, maxPlayers, motd) { const mcData = require('minecraft-data')(config.version); var server = mc.createServer({ "online-mode": config['online-mode'], host: config.host, port: config.port, maxPlayers: maxPlayers, motd: motd, version: config.version }); return server; } function createLoginPacket(server, client, hardcore, gameMode, viewDistance) { const mcData = require('minecraft-data')(server.version); var loginPacket = mcData.loginPacket; var data = { entityId: client.id, isHardcore: hardcore, gameMode: gameMode, previousGameMode: 255, worldNames: loginPacket.worldNames, dimensionCodec: loginPacket.dimensionCodec, dimension: loginPacket.dimension, worldName: 'minecraft:overworld', hashedSeed: [0, 0], maxPlayers: server.maxPlayers, viewDistance: viewDistance, reducedDebugInfo: false, enableRespawnScreen: true, isDebug: false, isFlat: false, }; return data; } function createPositionPacket(x, y, z, yaw, pitch) { var data = { x: x, y: y, z: z, yaw: yaw, pitch: pitch, flags: 0x00, }; return data; } function createClient(config, username, password) { var client = mc.createClient({ host: config.host, port: config.port, username: username, password: password, }); return client; } module.exports = { "createJsonMessage": createJsonMessage, "writeJsonMessage": writeJsonMessage, "emitEvents": emitEvents, "createServer": createServer, "createLoginPacket": createLoginPacket, "createPositionPacket": createPositionPacket, "createClient": createClient, };
Yeah its a issue, it happens in my proxy too it randomly crashes.
I have this exact same error. Any updates?
EDIT: The error is occurring on the following line:
https://github.com/ProtoDef-io/node-protodef/blob/e008e688d52478d82926888a59d85d79704ff462/src/serializer.js#L76
[!] The FAQ doesn't contain a resolution to my issue
Versions
Detailed description of a problem
I'm building proxy using minecraft-protocol only. But having 2 troubles. Player everytime kicked with error(without any errors in my proxy process).
And 2nd problem is
Current code
Expected behavior
Everytime, no matter what, player will be kicked.
Additional context
utils.js ->