Kel Posted March 2, 2016 Posted March 2, 2016 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 Quote
Ernio Posted March 2, 2016 Posted March 2, 2016 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). Quote 1.7.10 is no longer supported by forge, you are on your own.
Kel Posted March 2, 2016 Author Posted March 2, 2016 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 Quote
Ernio Posted March 2, 2016 Posted March 2, 2016 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). Quote 1.7.10 is no longer supported by forge, you are on your own.
Recommended Posts
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.