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

[1.7.10] [Solved] Gui wierdness. :/


Recommended Posts

I recently made a gui for a book. It was giving me a NullPointer so I had to change some things. I tested it and when I right clicked on it, it did this:


And it moves with my mouse:


I don't know what's wrong.

This is the texture I set:


Here is my code:



The GuiScreen:

public class GuiLexicon extends GuiScreen {
    int guiWidth = 192;
    int guiHeight = 256;

    static int GUI_ID = 30;

    public void drawScreen(int x, int y, float par3) {
        super.drawScreen(x, y, par3);

        ResourceLocation background = new ResourceLocation(SignificantAdvancements.MODID, "textures/guis/lexiconBackground.png");

        this.drawTexturedModalRect(x, y, 0, 0, guiWidth, guiHeight);

        int stringWidth = this.fontRendererObj.getStringWidth("Lexicon of Knowledge");

        this.fontRendererObj.drawString("Lexicon of Knowledge", guiWidth - stringWidth, 50, 0, true);


The GuiHandler:

public class GuiHandler implements IGuiHandler {
    public Object getServerGuiElement ( int ID, EntityPlayer player, World world, int x, int y, int z ) {
        return null;

    public Object getClientGuiElement ( int ID, EntityPlayer player, World world, int x, int y, int z ) {
        if ( ID == GuiLexicon.GUI_ID )
            return new GuiLexicon();

        return null;




If you need more code just ask. :)

Link to comment
Share on other sites

The reason it moves with your mouse is because you're drawing the texture to the position of your mouse in drawScreen(). You're passing the x and y coordinates given to you by drawScreen() to drawTexturedModalRect(), but these coordinates are the coordinates of the mouse. You need to pass it the position you want the texture to be drawn to.

I'm guessing the texture can't be found because I think you need to set your mod id to lowercase when you create a ResourceLocation, but I'm not positive on that one.

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.

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.


  • Create New...

Important Information

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