#Is there any way to close a gui? With commands or kubejs?

78 messages · Page 1 of 1 (latest)

plucky ore
#

See the title

misty gullBOT
#

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

hybrid grove
#

could use something like this in client_scripts:

ItemEvents.clientRightClicked('ftbquests:book', event => {
  if (event.hand != "MAIN_HAND") return
  if(!event.player.isCrouching()) return
  Client.setScreen(null)
  })
plucky ore
#

It would need to be in a server script

#

I am giving the player acces to the enderchest to save their inventorys and then teleport them, but I don't want them to be able to get their items back after the teleport, so I have to close the enderchestinterfaces somehow

#

If it is important, I use /enderchest from ftb to open it

glossy sphinx
#

You could do both

#

Client script receiving network packet to close screen

#

Tho there might be a method in player to close screen

#

player.closeContainer()?

plucky ore
glossy sphinx
#

you dont need to

glossy sphinx
plucky ore
#

I will try it

plucky ore
glossy sphinx
#

does it close anything?

#

like inventory maybe

plucky ore
#

Let me test

#

It doesn't close a normal chest either

#
    ```Is this wrong?
glossy sphinx
#

wouldnt that be e.player?

#

otherwise, where do you get player from

plucky ore
#

Idk, you just wrote player

#

I will test that

glossy sphinx
#

just paste your current code

plucky ore
#

Nope still doesn't work

#

I will try on a normal chest again

plucky ore
dense oreBOT
#

Paste version of events.js from @plucky ore

glossy sphinx
#

all I can say is jēbal. @keen edge check that one out raha ^

plucky ore
#

Is my code that bad?

glossy sphinx
#

its bulky

#

you should definitely reformat it at least

#

space out the events and make sure they dont cascade

#

like this shouldnt be happening

#

usually a sign of missing } or ) but in this case I think its just spacing

plucky ore
#

In my vscode it is not happening

glossy sphinx
#

I can see it is pepeLaugh

plucky ore
#

...

glossy sphinx
#

if(Math.random()<1.0){ is this some debug code? because this if statement will always be true

plucky ore
#

That has nothing to do with the enderchest not closing

plucky ore
glossy sphinx
#

where is that enderchest closing code supposed to go?

plucky ore
#

There were it is now

glossy sphinx
#

ah, found it

plucky ore
glossy sphinx
#

rest of the schedules work properly?

plucky ore
#

Yes everything works fine

glossy sphinx
#

hm

plucky ore
#

I built in the ..seconds left to test if the rest works

glossy sphinx
#

alright, then instead of e.player.closeContainer() you can change it to e.player.sendData('close_gui', null)

plucky ore
#

I will try that

glossy sphinx
#

and then make a client_scripts script:

NetworkEvents.dataReceived('close_gui', event => {
  Client.setScreen(null)
})
#

thats how you can send packets from server to client

plucky ore
#

I always think like this mod is too op, then someone tells me something like this

glossy sphinx
#

lol

plucky ore
#

It also doesn't close a normal chest

glossy sphinx
#

thats.. weird

plucky ore
dense oreBOT
#

Paste version of events.js, script.js from @plucky ore

glossy sphinx
#

what if you do just

NetworkEvents.dataReceived('close_gui', event => {
  Client.setScreen(null)
  console.log('Test')
})
#

does Test get printed to logs/kubejs/client.log?

#

and did you restart the game?

#

or at least run /kubejs reload client_scripts

#

since /reload only affects server scripts

plucky ore
#

I didn't know that sorry

#

I will test that quick

glossy sphinx
#

its mostly formatting

plucky ore
#

It now works thank you

glossy sphinx
#

not actually nested event callbacks

keen edge
#

oh thank god