Hello everyone, this may be more of a Java question but I couldn't find anything helpful on the internet.
I'm in the following scenario: when a player opens a chest (inventory gui), my mod will make a http get request (which might take a while if the server is slow), and then update the chest contents depending om the response. And, before the request finishes, there will be "Loading..." message displayed.
However, when putting all code in main thread, while the game waits for response, the fps drops to zero as expected. If I make the request in a separate thread, no blocking occurs but I've read in a lot of places that one should not call Minecraft functions from threads other than the main one. If I set a callback function for http request, it gets executed in another thread, too.
So I'm wondering how can I do the non-blocking request and await it's completion. I've looked into java.util.concurrent classes but every approach I tried resulted in either blocking or calling minecraft code from another thread.
Any help is appreciated, and apologies if this question is not well suited for this forum, I haven't found a better place to ask.