Jump to content

[1.8][Nevermind] player.openGui vs sending packet.


Ernio

Recommended Posts

So I kinda touched piece of code I wrote long ago.

 

Anyway:

player.openGui, when called on: (logical side)

* Client = will ONLY call #getClientGuiElement

* Server = will call #getServerGuiElement and send packet to client that will call #getClientGuiElement.

 

Yeah, all cool, so what's the problem?

 

Try calling player.openGui in PlayerEvent.PlayerLoggedInEvent.

 

Logically - it SHOULD open gui on client (given client has gui assigned to proper id).

It doesn't.

At first i though that maybe someone forgot about thread safety, but nope (OpenGuiHandler) - it is there.

 

So question arises:

Why does this work:

@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
Network.sendTo(new PacketSendGui((byte) 1), (EntityPlayerMP) event.player);
}

@Override
public IMessage handleClientMessage(final EntityPlayer player, final PacketSendGui message, MessageContext ctx)
{
Minecraft.getMinecraft().addScheduledTask(new Runnable()
{
	public void run()
	{
		player.openGui(RoAMain.instance, message.id, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
});
return null;
}

And this doesn't:

public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
event.player.openGui(Main.instance, 1, event.player.worldObj, (int) event.player.posX, (int) event.player.posY, (int) event.player.posZ);
}

 

I mean - it's literally same routine.

 

<Looks at Guru diesieben>

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.

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.



×
×
  • Create New...

Important Information

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