April 16, 201510 yr You can try copying code from Vazkii's book https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java
April 16, 201510 yr I copied some of the code, it centers, but now it's acting like a gui in my previous mod did: Here is my code: int guiWidth = 192; int guiHeight = 256; int top; int left; static int GUI_ID = 30; private static String[] titlePageUntranslated = { "lexicon.titlePage.title.text" }; private static String[] titlePageLocalized; private static LexiconPage currentPage = null; @Override public void initGui(){ super.initGui(); left = width / 2 - guiWidth / 2; top = height / 2 - guiHeight / 2; } @Override public void drawScreen(int mouseX, int mouseY, float par3) { super.drawScreen(mouseX, mouseY, par3); ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayWidth); int backX = sr.getScaledWidth(); int backY = sr.getScaledHeight(); this.drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); int stringWidth = this.fontRendererObj.getStringWidth("Lexicon of Knowledge"); ResourceLocation background = new ResourceLocation(SignificantAdvancements.MODID, "textures/guis/lexiconBackground.png"); Minecraft.getMinecraft().renderEngine.bindTexture(background); this.fontRendererObj.drawString("Lexicon of Knowledge", guiWidth - stringWidth, 50, 0x00FFFF, true); }
April 16, 201510 yr wait, lol in all the confusion my texture binding code got moved down. I'll test it now.
April 16, 201510 yr Ok, it woked for about 2 seconds then it gave me an OutOfMemory Exception. I really hate my computer. 2 Gbs of RAM? Come on Dell, why would you do this to me?
April 16, 201510 yr But, regardless of how Dell is really a pain in the butt sometimes, it works now. Thanks everyone.
April 16, 201510 yr About they aren't there... Just add them and define in constructor! And also, code for your gui, centered (just replace whole class GuiLexicon with that and it will work): public class GuiLexicon extends GuiScreen { int guiWidth = 192; int guiHeight = 256; int guiLeft = 0; int guiTop = 0; public GuiLexicon() { guiLeft = (width - guiWidth) / 2; guiTop = (height - guiHeight) / 2; } static int GUI_ID = 30; @Override public void drawScreen(int mouseX, int mouseY, float par3) { super.drawScreen(mouseX, mouseY, par3); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(SignificantAdvancements.MODID, "textures/guis/lexiconBackground.png")); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, guiWidth, guiHeight); int stringWidth = this.fontRendererObj.getStringWidth(I18n.format("lexiconOfKnowledge.lang")); this.fontRendererObj.drawString(I18n.format("lexiconOfKnowledge.lang"), guiWidth - stringWidth, 50, 0x00FFFF, true); } } Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
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.