Posted January 13, 201312 yr Hey guys. I'm working on a mod. There are two new blocks. Each block should open a GUI with a right mouse button. Problem: The GUI don't open. No Errors. No messages in the console in eclipse. Each block have an onBlockActivated like this, only the ID in par5EntityPlayer.opengui are different(0-1). public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } else if (!par5EntityPlayer.isSneaking()) { TileEntity var10 = (TileEntity) par1World.getBlockTileEntity(par2, par3, par4); if (var10 != null) { par5EntityPlayer.openGui(Basis.instance, 0, par1World, par2, par3, par4); } return true; } else { return false; } } Also I have an GuiHandler class with the methods getServerGuiElement and getClientGuiElement getClientGuiElement: public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getBlockTileEntity(x, y, z); if (entity == null) { switch (ID) { case 0: return new GuiBlock1(player.inventory, ((TileEntityBlock1) entity)); case 1: return new GuiFlock2(player.inventory, ((TileEntityBlock2) entity)); } } return null; } getServerGuiElement: public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getBlockTileEntity(x, y, z); if (entity == null) { switch (ID) { case 0: return new ContainerBlock1(player.inventory, ((TileEntityBlock1) entity)); case 1: return new ContainerBlock2(player.inventory, ((TileEntityBlock2) entity)); } } return null; } And in the main class I added this: public static GuiHandler handler; NetworkRegistry.instance().registerGuiHandler(instance, handler);
January 13, 201312 yr Author First of all you don't need to check for player sneaking, it is done by vanilla since on of the recent versions. Then you should not reference your GuiScreens directly in your GuiHandler because that will make your mod only work in SP. Instead give that off to your ClientProxy. For debugging you should try putting in System.out.println() calls in your GuiHandler to see if the methods that open your Gui are actually called. Also make sure you are a @NetworkMod. The blocks are furnaces, thats why I'm checking for sneaking. The methods don't get called. The mod is a networkmod. @NetworkMod(clientSideRequired = true, serverSideRequired = false) But I don't understand what you mean with: Then you should not reference your GuiScreens directly in your GuiHandler because that will make your mod only work in SP. Instead give that off to your ClientProxy. Can you give me an example to understand this? Thanks
January 13, 201312 yr Author For goodness' sake! I'm such a noob! All I had to do is to implements IGuiHandler to the ClientProxy and to copy the methods from my guihandler class to Clientproxy. Damnit! Now i know this for the future. Thanks a lot man! Greeting from Germany /Offtopic P.S.: I'm know like 1000% more happy!
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.