Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);

@Override
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

Use Player.openGui() like you should. ModLoader's openGUI is only clientside ever.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Both sides you use Player.openGUI

Try reading the IGuiHandler.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

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?

  • Author

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

The server needs to return a Container.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.