I'm new at gui's so bear with me on this one. I'm trying to make the crafting gui open whenever the player right clicks on my entity. The entity and renderer are working fine, but it's the gui I'm having trouble with. I tried doing this:
FMLClientHandler.instance().displayGuiScreen(player, new GuiCrafting(player.inventory, player.worldObj, new BlockPos((int)player.posX, (int)player.posY, (int)player.posZ)));
and the gui opens, but whenever I pick up an ItemStack it puts it back down, picks up the ItemStack to the left, and then shuffles the entire inventory. I knew that couldn't be right, so I tried this, which is the vanilla crafting table code:
player.displayGui(new BlockWorkbench.InterfaceCraftingTable(player.worldObj, new BlockPos((int)player.posX, (int)player.posY, (int)player.posZ)));
but then the gui just flickered open for a second, and then closed. Then, I tried to make my own gui handler, which looks like this:
// Imports
public class CraftingGuiHandler implements IGuiHandler {
@Override
public Object getClientGuiElement(int arg0, EntityPlayer player, World world, int x, int y, int z) {
return new GuiCrafting(player.inventory, world);
}
@Override
public Object getServerGuiElement(int arg0, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z));
}
}
I tryed opening it with this:
player.openGui(MyMod.Instance, 0, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ);
but it just flickered again! Any help would be appreciated, because I'm out of ideas. Thanks!