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.