Jump to content

Open GUI on connect


Recommended Posts



So, recently I started my mod, which is designed to be played multiplayer without any other mod.

In this mod, the server send a "OpenGui" Message/Packet, and the client need to open a GUI in which he will put a first name and a last name. Then the client need to send back a "SetName" Message/Packet.

Right now I implemented this as is:

- PlayerLoggedInEvent detect a player connection. After checking that the world !isRemote, I send a OpenGuiMessage(Login) to the player

- When the client receive "OpenGuiMessage(Int)" it opens the Gui "Int" with a simple "mc.displayGuiScreen"


The problem is that actually, the Gui pops up just before Minecraft load the render, so a few ms after the screen shows, it closes to have currentScreen == null & GuiIngame.


It is not even visible, though my PC got laggy during the connection so I had time to see the GuiScreen poping up then closes..


How can I wait the render has been done to open the Gui (Or opening it directly without showing the Game first)



Thanks in advance

Link to comment
Share on other sites

This will work. It is just that you are doing something else wrong.


You are opening gui from Netty Thread (packet). What you need to do, and not only in this case, but in ALL your packets is to pass task to MC's thread.


For Client:

Minecraft.getMinecraft().addScheduledTask(new Runnable() ...


For Server:

player.getServerForPlayer().addScheduledTask(new Runnable() ...

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

mmh actually I'm not that done..

I am doing pretty much the same thing, once the player has set it server-side, I send another packet to sync the ExtandedProperties:

public IMessage handleClientMessage(final EntityPlayer player, final UpdateClientMessage message, MessageContext ctx) {
		final Minecraft mc = Minecraft.getMinecraft();
		mc.addScheduledTask(new Runnable() {
			public void run() {
				System.out.println("Tries to get it");
				PlayerProps pp = PlayerProps.get(player);
				System.out.println("Got it: " + pp.toString());
				pp.setName(message.fName, message.lName);
		return null;

Then I get it at each connect. It works the first time when I set my name, but then as soon as I connect it does nothing. When I take out the task, it kicks me out and the log says that "NullPointerException" on PlayerProps.get



I have no clue how to register it since I already do this:

public void onEntityConstructing(EntityConstructing evt) {
	if (evt.entity instanceof EntityPlayer && PlayerProps.get((EntityPlayer)evt.entity) == null) {


NOTE that it does work without problems singleplayer


EDIT: Actually, it works some times, and some other it doesn't.. I can't find how to reproduce working / non working.

By "Some time" I mean, when I connect, and that it doesn't work, I disconnect and reconnect, untill it works. Tough when I disconnect and reconnect it is not mandatory that it works...

Link to comment
Share on other sites

Well. It worked for me in 1.8, 1.8.9 and now in 1.9.


Best shot: Post whole src on Git.


If not... you could call Skype (ernio333), since I've got some time (TeamViewer preferred).

1.7.10 is no longer supported by forge, you are on your own.

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.

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.

  • Create New...

Important Information

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