uiytt Posted March 25, 2020 Share Posted March 25, 2020 (edited) So, I have two thread : The first one is the one of minecraft, the second one is async thread that I created to do something on the web. I would like that when the second thread is done, the first thread execute a method ( and not the second thread because minecraft really doesn't like when you use method using another thread). Before the second thread ended, the first thread must continue working. Does anyone have any idea of how to do that please ? Edited March 25, 2020 by uiytt Clarification Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted March 25, 2020 Share Posted March 25, 2020 Hi You could consider using the packet receiving system to do that. Any time a packet is received, it is in a network thread. The network thread creates a Runnable lambda which is then executed in either the client thread or the server thread. Some more info here: http://greyminecraftcoder.blogspot.com/2020/03/thread-safety-with-network-messages-1144.html There's probably a way for your second thread to add your own Runnable lambda to those queues without using packets. Alternatively, you could perhaps subscribe to a Tick event on the server or the client, and every tick check your second thread to see whether it has finished executing or not. -TGG 1 Quote Link to comment Share on other sites More sharing options...
uiytt Posted March 27, 2020 Author Share Posted March 27, 2020 Well I tried : Minecraft.getInstance().runImmediately(new Runnable() { @Override public void run() { MultiPlayerGui.this.minecraft.displayGuiScreen(new ConnectingScreen(MultiPlayerGui.this, MultiPlayerGui.this.minecraft, server)); } }); And it's really weird... In my console, I receive everything from the server chat. But on my game, it's stuck on loading the terrain infinitely !!! MultiPlayerGui is my custome class but the rest is not.. I don't undersant why O_o Quote Link to comment Share on other sites More sharing options...
uiytt Posted March 28, 2020 Author Share Posted March 28, 2020 (edited) 7 hours ago, diesieben07 said: Any reason you are using runImmediately? Whats the thread that this is called from? A thread that I created to check for my server's information. If I use the screen directly from my thread, minecraft will crash.. Edited March 28, 2020 by uiytt Quote Link to comment Share on other sites More sharing options...
uiytt Posted March 31, 2020 Author Share Posted March 31, 2020 No Idea ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.