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.

[1.8.9] [Forge 11.15.1.1722] Having trouble with a GUI regarding block click

Featured Replies

Posted

I have written code for a block that acts somewhat like a furnace.  I will edit how it works once I get the gui running, but for now I am having trouble getting the gui to open.  The game starts up properly, and will load the world, but when I click the block it doesn't run onBlockActivated from what I can tell.  I don't get a crash as well, so I think it isn't running the code to open the gui.  I have included every relevant class.  Any help would be appreciated.

 

All files are on the github

Focus is on BasicCrusher, Intricateoreprocessing, and GuiHandler.

 

GITHUB LINK:

https://github.com/KelCo/CodeHelp

And this is why Java has @Override.

You are not overriding "real" method.

 

Then 2nd mistake:

IGuiHandler works this way: (when you call player.openGUI)

On Client:

* Calls client method and opens Gui or null.

On Server:

* Calls server method and IF that method returns Container instance then:

** Container is opened on server.

** Packet is sent to client with data: id, x, y, z.

** Client calls client method and opens client Gui.

If the server method will return NULL - nothing happends (on client too).

 

Following that: When you call player.openGui(...) in onBlockActivated - call it on !world.isRemote! (otherwise you are opening gui twice which if not harmful - is still useless).

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

  • Author

Thank you Ernio, but I'm still a little confused on some things.

 

First, to clarify, I'm assuming when you said I wasn't overriding the "real" method that you were referring to the ones in GuiHandler.java. Am I correct in this assumption or were you talking about something else?

 

Second, I made the last change that you suggested about running player.openGui() on !world.isRemote instead.

 

Lastly though, I understand what you're saying by your "2nd mistake" but I'm unsure what you're instructing me to do by informing me of this. If you could get back to me sometime soon, that would be fantastic.

Thank you very much Ernio

i am refering to Block's code - it is not called because it is not a real method:

public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, int x, int y, int z)

 

Go to your IDE preferences and set it to format your code on saving (Eclipse has it, idk about other). If you can't track mistakes like that (seems like part of copy-pasted code) then there is nothing bad in making IDE track them for you.

 

Anyway - yeah, that is the main reason why nothing works.

 

Also side note - your code is badly designed - no problems in that, but just pointing that out - get some more java exp and rewrite it (e.g: too many "ClientSideOnly" classes and other - thay can be packed together).

 

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

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.