Posted April 12, 201510 yr 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; @Override public void drawScreen(int x, int y, float par3) { super.drawScreen(x, y, par3); ResourceLocation background = new ResourceLocation(SignificantAdvancements.MODID, "textures/guis/lexiconBackground.png"); Minecraft.getMinecraft().renderEngine.bindTexture(background); 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 { @Override public Object getServerGuiElement ( int ID, EntityPlayer player, World world, int x, int y, int z ) { return null; } @Override 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.
April 12, 201510 yr 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.
April 12, 201510 yr Well thanks. I fixed the textures. My item for my book was that missing texture thingy. I found my resource directory was formatted weird. I'm still getting used to intelliJ IDEA. But thanks for telling me about my mistake about mouse coordinates.
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.