Jump to content

Detect when GUI closes


KaptainWutax

Recommended Posts

So, Im creating a MIDI block. When you right click it, it opens a GuiScreen (no container) and using a button, you can open midi devices connected to your computer and play music in-game. Only issue tho, when i leave the GUI, i want to close the MIDI Reciever. Unfortunately, I havent found a way to detect when it closes.

I have some ideas but I don't feel like they are optimal.
-Check if player clicks ESC before closing the Reciever. Unfortunately, you can leave a GUI without pressing ESC by dying or when the TileEntity gets destroyed.
-Using player capabilities. It might be a little overkill for this case.
-Constantly be checking if` Minecraft.getMinecraft().thePlayer.currentScreen == null` Its pretty resource intensive though.

 

Anyone know how I could do it in an efficient way?

Thank you in advance and thanks for taking the time to read until here.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.