KubeJS

KubeJS

69M Downloads

Network Packets do not send data

ChiefArug opened this issue ยท 0 comments

commented

Trying to use network packets to send data between client and server.
Inside serverscripts:

onEvent('item.right_click', event => {
    event.player.sendData('not_working', {test: "data exists, ya know!"})
})

inside client scripts:

onEvent('player.data_from_server.not_working', event => {
    console.log('Boop')
    console.log(m.data + 'Beep')
    console.log(m.getData(test) + 'Bip')
})

The logs after right clicking:

[16:15:30] [INFO] Boop
[16:15:30] [INFO] nullBeep
[16:15:30] [ERR ] Error occurred while handling event 'player.data_from_server.not_working': ReferenceError: "test" is not defined. (client_scripts:script.js#4)

As you can see the packet is received, but neither of the ways of getting data works. I have also check with a for loop and event.data is a completely empty object.
Tested on single player and on a dedicated server (running on the same pc and connecting through localhost)