#Help opening a GUI on right click

7 messages · Page 1 of 1 (latest)

acoustic tulip
#

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

toxic vaultBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

acoustic tulip
#

#archived-example-scripts message

#

this is where i got the code from btw

amber karma
#

crafting requires an associated table in the world trigged by the server in a certain way and iirc it is not very possible with KubeJS, but I may be wrong

toxic vaultBOT
#

@acoustic tulip Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!

toxic vaultBOT
#

@acoustic tulip Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!