a similar question was asked asked a few weeks ago but i couldn't get the answer to work for me
the code is basically copy pasted from the post
i have a server script that sends data to a client when a block is clicked:
onEvent('block.right_click', event => {
if (event.block.id != "kubejs:crafting_carpet") return
if (event.hand != "MAIN_HAND") return
event.player.sendData('open_crafting', {message: ''})
})
then i have a client script that tries to open the crafting table GUI when it gets the data
const CraftingScreen = java('net.minecraft.client.gui.screens.inventory.CraftingScreen')
onEvent('player.data_from_server.open_crafting', event => {
event.player.tell('works')
Client.setCurrentScreen(new CraftingScreen())
})
the message gets sent to the player but the screen does not open