Jump to content

Recommended Posts

Posted

Hi I would know, what is the code for open a specific Gui when a player right click with a specific object.

I know the code with modloader but not the one with forge

 

public class livredecartes extends Item
{
    public livredecartes(int i)
    {
        super(i);
        maxStackSize = 64;
        this.setCreativeTab(CreativeTabs.tabMaterials);
    }

    public String getTextureFile()
    {
            return "/chewdri/harrypotterv2/client/Items.png";
    }
    
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
    ModLoader.openGUI(par2EntityPlayer,new GuiWithButtonr(par2EntityPlayer)); 
    return true;
    }
}

 

 

Posted

I tried

 

public boolean onItemUse(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t)
    {
            
   
    	player.openGui(harrypotterv2.instance, GuiWithButtonr.ID, world, 0, 0, 0);
            return true;
            }
    
    
}

 

0 errors, but I open anything when I right click with my item

Posted

Hello!

 

Blaueseichoern has some great GUI tutorials over on the minecraft forums.  In post 4 he has a tutorial for the exact thing you are trying to accomplish :)

Also the other GUI tutorials are working with forge as well, so it should give you a good read :)

 

If you guys dont get it.. then well ya.. try harder...

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.