How to open and close a GUI with the same keybind?

Started by Bulb on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to open and close a GUI with the same keybind?
Sat, 09/28/2024 - 15:04 (edited)

So, how to make a keybind, which can open and close the same GUI. You open it, for example with "K", and close it with "K", not only ESC button. 
My MCreator version is 2024.1 , I'm making a mod for Java Minecraft 1.20.1 Forge.
The only thing I want is a Java code for opening GUI with the same keybind with commentaries or a MCreator procedure screenshot. 
Thank you in advance, sincerely!

Edited by Bulb on Sat, 09/28/2024 - 15:04
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if have gui open, closeif…
Sat, 09/28/2024 - 16:26

if have gui open, close
if not have gui open, open it

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Please, send a screenshot or…
Sat, 09/28/2024 - 22:45

Please, send a screenshot or smth, because it doesn't work

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
On key [K] pressed If [is…
Tue, 10/01/2024 - 12:31

On key [K] pressed

If [is gui {custom gui} currently opened for event target entity] = [true]

    Close open gui

Else [open gui {customgui} ]

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It still doesn't work. The…
Mon, 10/07/2024 - 19:05

It still doesn't work. The GUI opens, but doesn't close