Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.12 Custom Gui Not Showing


DragonFerocity
 Share

Recommended Posts

Hey guys,

 

I'm having trouble getting a custom gui to show up. I'm trying to create a new furnace that is a direct upgrade to the regular furnace. Internally, I have called it the Alloy Furnace.

 

My issue is that the custom gui I've created doesn't show up when I right click the new furnace. It shows my players inventory and that's it. And then on subsequent right clicks, the gui doesn't show up anymore.

 

Here's my code on GitHub.

 

And relevant files for the furnace are at:

src\main\java\com\DragonFerocity\expanded\handlers\GuiHandler.java

src\main\java\com\DragonFerocity\expanded\inventory\ModContainerAlloyFurnace.java

src\main\java\com\DragonFerocity\expanded\entities\ModTileEntityAlloyFurnace.java

src\main\java\com\DragonFerocity\expanded\gui\ModGuiAlloyFurnace.java

src\main\java\com\DragonFerocity\expanded\blocks\ModAlloyFurnace.java

Link to comment
Share on other sites

I did that, and the gui still doesn't open properly. Here's my updated GuiHandler code:

 

@SideOnly(Side.CLIENT)
public class GuiHandler implements IGuiHandler
{

    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) 
    { 
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        System.out.println("Server GUI ----------------------------------------------------------------------------");

        if (tileEntity != null)
        {
            if (ID == BlockHandler.GUI_ENUM.ALLOY_FURNACE.ordinal())
            {
                return new ModContainerAlloyFurnace(player.inventory, (ModTileEntityAlloyFurnace)tileEntity);
            }
        }

        return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        System.out.println("Client GUI ----------------------------------------------------------------------------");

        if (tileEntity != null)
        {
            if (ID == BlockHandler.GUI_ENUM.ALLOY_FURNACE.ordinal())
            {
                return new ModGuiAlloyFurnace(player.inventory, (ModTileEntityAlloyFurnace)tileEntity);
            }
        }
        return null;
    }
}

 

Link to comment
Share on other sites

Still doesn't work then. I did this before as well, just forgot to mention it.

 

public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  {
      if (worldIn.isRemote)
      {
          return true;
      }
      else
      {
          TileEntity tileentity = worldIn.getTileEntity(pos);

          if (tileentity instanceof ModTileEntityAlloyFurnace)
          {
              playerIn.openGui((Object)ExpandedAesthetics.class, BlockHandler.GUI_ENUM.ALLOY_FURNACE.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
              playerIn.addStat(StatList.FURNACE_INTERACTION);
          }

          return true;
      }
  }

 

Link to comment
Share on other sites

I tried

playerIn.openGui((Object)ExpandedAesthetics.instance, BlockHandler.GUI_ENUM.ALLOY_FURNACE.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());

and

playerIn.openGui("ExpandedAesthetics", BlockHandler.GUI_ENUM.ALLOY_FURNACE.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());

 

Neither worked, and now the gui doesn't even show up on a right click.

Link to comment
Share on other sites

8 minutes ago, diesieben07 said:

The mod object needs to be either your mod class' instance (not the java.lang.Class instance), you can use the @Instance annotation to retrieve it, or your mod ID as a String.

 

And the concept of a "common proxy" makes no sense. A proxy is inherently designed for side-specific operations. Common code does not need a proxy, that is just adding a useless layer of indirection.

Link to comment
Share on other sites

If I keep the line of code:

NetworkRegistry.INSTANCE.registerGuiHandler(ExpandedAesthetics.instance, new GuiHandler());

in the ExpandedAesthetics::preInit function, it crashes.

If I replace ExpandedAesthetics.instance with "expandedaesthetics" it still crashes.

Quote

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Expanded Aesthetics (expanded)
Caused by: java.lang.NullPointerException

 

Here's my instance variable:

@Instance("ExpandedAesthetics")
public static ExpandedAesthetics instance;

 

Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.