Jump to content

Multiplayer GUI Problem


Recommended Posts

I can't get the GUI to open on the blocks. I am not sure how to do this. I read the FML porting tutorial.


I have this in both server and client and I registered it via

MinecraftForge.setGuiHandler(this, this);

public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
	System.out.println("WORKING "+ID);
	return null;


On the blockActivated function I simply called ModLoader.openGUI(...) in both client and server side.


It never prints that line. Not sure why...


You can check out the full code here: https://github.com/calclavia/Universal-Electricity/tree/master/Universal_Electricity


Changes are in UCBlockMachine, mod_UniversalElectricity

Link to comment
Share on other sites

Both sides you use Player.openGUI

Try reading the IGuiHandler.


Thanks! It works now! Is it possible to have more than one GUI handler in a mod? It doesn't really feel neat if I have all my GUIs handled at one location. But if there is no option, that is fine. That is just for coding aesthetics.


One more question though. My tile entity saves NBT data and stuff. How do I make sure those datas are synced with the client? Or are they synced automatically themselves when I do an NBT save?

Link to comment
Share on other sites

Both sides you use Player.openGUI

Try reading the IGuiHandler.


OK. I accidentally lied. The GUI still doesn't open up on multiplayer. I am not sure what I am doing wrong. I have both server and client using IGuiHandler. I have ONLY the client doing action with the IGUIHandler because the server can not have a GUI class inside of it.


Here are the sources. Scroll to the very bottom for the GUI handle function.


CLIENT GUI HANDLER: https://github.com/calclavia/Universal-Electricity/blob/master/minecraft/net/minecraft/src/universalelectricity/components/UniversalComponents.java


SERVER GUI HANDLER: https://github.com/calclavia/Universal-Electricity/blob/master/minecraft_server/net/minecraft/src/mod_UniversalElectricity.java

Link to comment
Share on other sites

I have another problem now though. The data of the tile entity seems to not be syncing with the server. I did some print line tests and the server had all the variables set correctly, but on the client side the variables are not correct. How would I make sure those variables in the tile entities are synced?


EDIT: I tried using packets to send the data. But things start to get really messy. Is there any structured way I can send data packets?

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.