Posted March 24, 20169 yr Hello, I'm updating my mod to 1.9, can't get GUIs to open. onBlockActivated is called but GUI doesn't show up @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { System.out.println("onBlockActived was called! Trying to open GUI"); playerIn.openGui(More.instance, 0, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } } Here is my GuiHandler: public class MoreGuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); TileEntity tile_entity = world.getTileEntity(pos); switch (id) { case 0: return id == 0 && world.getBlockState(pos).getBlock() == MoreBlocks.inventor_table ? new ContainerInventorTable( player.inventory, world, pos) : null; case 1: return id == 1 && ((world.getBlockState(pos).getBlock() == MoreBlocks.uranium_furnace) || (world.getBlockState(pos).getBlock() == MoreBlocks.lit_uranium_furnace)) ? new ContainerUraniumFurnace( player.inventory, (TileEntityUraniumFurnace)tile_entity) : null; case 2: return id == 2 && ((world.getBlockState(pos).getBlock() == MoreBlocks.uranium_compressor) || (world.getBlockState(pos).getBlock() == MoreBlocks.lit_uranium_compressor)) ? new ContainerUraniumCompressor( player.inventory, (TileEntityUraniumCompressor) tile_entity) : null; } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); TileEntity tile_entity = world.getTileEntity(pos); switch (id) { case 0: return id == 0 && world.getBlockState(pos).getBlock() == MoreBlocks.inventor_table ? new InventorTableGui( player.inventory, world) : null; case 1: return id == 1 && ((world.getBlockState(pos).getBlock() == MoreBlocks.uranium_furnace) || (world.getBlockState(pos).getBlock() == MoreBlocks.lit_uranium_furnace)) ? new UraniumFurnaceGui( player.inventory, (TileEntityUraniumFurnace)tile_entity) : null; case 2: return id == 2 && ((world.getBlockState(pos).getBlock() == MoreBlocks.uranium_compressor) || (world.getBlockState(pos).getBlock() == MoreBlocks.lit_uranium_compressor)) ? new UraniumCompressorGui( player.inventory, (TileEntityUraniumCompressor) tile_entity) : null; } return null; } } Thanks in advance!
March 24, 20169 yr That return statements are a total mess. Why are you asking two times if your id is 0/1/2 etc? Did you register the handler? Are you doing some basic debugging, like checking if your guihandler gets called?
March 24, 20169 yr Author Seems I removed registering line while was testing other things and forgot to return it back thanks for help.
March 24, 20169 yr You need to call openGui on both the client and the server. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
March 24, 20169 yr You need to call openGui on both the client and the server. nope. you need to open the gui on server, it will inform the client
March 24, 20169 yr You need to call openGui on both the client and the server. This is not true. When called on the server side, EntityPlayer#openGUI sends a packet to the player's client that opens the appropriate GuiScreen . Calling it on the client side will open the GuiScreen , but this will be replaced as soon as the packet is received from the server. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.