Jump to content

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


Recommended Posts

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

Posted

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.

Posted

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

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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