You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] The FAQ doesn't contain a resolution to my issue
Versions
minecraft-protocol: 1.47.0
server: vanilla/spigot/paper #.#.#
node: 21.7.3
Detailed description of a problem
When trying to join the example server in examples/server/server.js with a vanilla Minecraft 1.20.1 client, it disconnects with the message Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonParseException: Don't know how to turn {} into a Component!.
Current code
constmc=require('minecraft-protocol')constnbt=require('prismarine-nbt')constoptions={motd: 'Server','max-players': 1,port: 25565,'online-mode': false,version: "1.20.1"}constserver=mc.createServer(options)constmcData=require('minecraft-data')(server.version)constloginPacket=mcData.loginPacketfunctionchatText(text){returnmcData.supportFeature('chatPacketsUseNbtComponents')
? nbt.comp({text: nbt.string(text)})
: JSON.stringify({ text })}server.on('playerJoin',function(client){broadcast(client.username+' joined the game.')constaddr=client.socket.remoteAddress+':'+client.socket.remotePortconsole.log(client.username+' connected','('+addr+')')client.on('end',function(){broadcast(client.username+' left the game.',client)console.log(client.username+' disconnected','('+addr+')')})// send init data so client will start rendering worldclient.write('login',{
...loginPacket,entityId: client.id,isHardcore: false,gameMode: 0,previousGameMode: 1,hashedSeed: [0,0],maxPlayers: server.maxPlayers,viewDistance: 10,reducedDebugInfo: false,enableRespawnScreen: true,isDebug: false,isFlat: false})client.write('position',{x: 0,y: 256,z: 0,yaw: 0,pitch: 0,flags: 0x00})functionhandleChat(data){constmessage='<'+client.username+'>'+' '+data.messagebroadcast(message,null,client.username)console.log(message)}client.on('chat',handleChat)// pre-1.19client.on('chat_message',handleChat)// post 1.19})server.on('error',function(error){console.log('Error:',error)})server.on('listening',function(){console.log('Server listening on port',server.socketServer.address().port)})functionsendBroadcastMessage(server,clients,message,sender){if(mcData.supportFeature('signedChat')){server.writeToClients(clients,'player_chat',{plainMessage: message,signedChatContent: '',unsignedChatContent: chatText(message),type: 0,senderUuid: 'd3527a0b-bc03-45d5-a878-2aafdd8c8a43',// randomsenderName: JSON.stringify({text: sender}),senderTeam: undefined,timestamp: Date.now(),salt: 0n,signature: mcData.supportFeature('useChatSessions') ? undefined : Buffer.alloc(0),previousMessages: [],filterType: 0,networkName: JSON.stringify({text: sender})})}else{server.writeToClients(clients,'chat',{message: JSON.stringify({text: message}),position: 0,sender: sender||'0'})}}functionbroadcast(message,exclude,username){sendBroadcastMessage(server,Object.values(server.clients).filter(client=>client!==exclude),message)}
Expected behavior
I expected the client to be able to join the server normally and be able to send messages in the chat.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Server example here is not maintained, it might be broken. Hard to know as it's not really possible to create a connectable server without a full server implementation or proxy. I think the best way we can make sure the nmp server implementation is updating flying-squid.
[ ] The FAQ doesn't contain a resolution to my issue
Versions
Detailed description of a problem
When trying to join the example server in examples/server/server.js with a vanilla Minecraft 1.20.1 client, it disconnects with the message
Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonParseException: Don't know how to turn {} into a Component!
.Current code
Expected behavior
I expected the client to be able to join the server normally and be able to send messages in the chat.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: