Posted July 10, 201312 yr How can i draw an icon on a guiScreen properly? i am familliar with the method and all but there is just a little problem. when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet. so it doesnt draw anything visible. do i need to bind the icon somehow to make it work? this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16); http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
July 10, 201312 yr How can i draw an icon on a guiScreen properly? i am familliar with the method and all but there is just a little problem. when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet. so it doesnt draw anything visible. do i need to bind the icon somehow to make it work? this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16); You are way off for gui screens there buddy. Use this: Static: public ResourceLocation guiLocation = new ResourceLocation(Core.DirTexPre + Core.DirGui + "CyphScapeLogo" + Core.DirEnd); DrawScreen public void drawScreen(int i,int j, float f) { drawDefaultBackground(); /** * Renders Images * */ this.mc.func_110434_K().func_110577_a(this.guiLocation); int posX2 = (this.width - xSizeOfTexture) / 1; int posY2 = (this.height - ySizeOfTexture) / 3; drawTexturedModalRect(posX2 - 100, posY2 - 45, 0, 0, xSizeOfTexture, ySizeOfTexture);
July 10, 201312 yr How can i draw an icon on a guiScreen properly? i am familliar with the method and all but there is just a little problem. when i use the drawTexturedModelRectFromIcon method it draws from an empty sheet. so it doesnt draw anything visible. do i need to bind the icon somehow to make it work? this.drawTexturedModelRectFromIcon(this.xPosition+3, this.yPosition+3, PetMastery.petEgg.getIconFromDamage(0), 16, 16); You are way off for gui screens there buddy. Use this: Static: public ResourceLocation guiLocation = new ResourceLocation("PIC LOCATION HERE"); DrawScreen public void drawScreen(int i,int j, float f) { drawDefaultBackground(); /** * Renders Images * */ this.mc.func_110434_K().func_110577_a(this.guiLocation); int posX2 = (this.width - xSizeOfTexture) / 1; int posY2 = (this.height - ySizeOfTexture) / 3; drawTexturedModalRect(posX2 - 100, posY2 - 45, 0, 0, xSizeOfTexture, ySizeOfTexture); Edit: Just take the icon and save it to a 256x256 picture and align to the top right. Then go in here and change the x and y to 16. that should load it. Crap sorry wrong button. I forgot this: public final int xSizeOfTexture = 256; //The x value of the picture public final int ySizeOfTexture = 100; // The y value of the picture. put them above the draw background.
July 10, 201312 yr Author that doesnt seem very usefull... i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working. http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
July 10, 201312 yr that doesnt seem very usefull... i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working. if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3.
July 11, 201312 yr Author that doesnt seem very usefull... i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working. if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3. lol? i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class. it has to work somehow i just dont know how. http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
July 12, 201312 yr that doesnt seem very usefull... i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working. if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3. lol? i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class. it has to work somehow i just dont know how. ... Do what I just told you. Make a new picture and put the icon there! Otherwise go look at the source for ee3.
July 12, 201312 yr This will bind the blocks atlas this.mc.func_110434_K().func_110577_a(TextureMap.field_110575_b); This will bind the items atlas this.mc.func_110434_K().func_110577_a(TextureMap.field_110576_c); After binding one of those you can use an icon with drawTexturedModelRectFromIcon That only seems to work with the default blocks and items though, as it wouldn't draw the correct icon for any of my stuff. I figure there is another atlas for mod stuff but with nothing named I couldn't find it. So I wrote a simple work around. (its based off of drawTextureModelRectFromIcon) /** * Draws a texture at the given location, with the specified size * @param x Location X * @param y Location Y * @param w Draw Width * @param h Draw Height */ public void drawTexture(int x, int y, int w, int h) { GL11.glColor4f(1F, 1F, 1F, 1F); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0, y + h, this.zLevel, 0D, 1D); tessellator.addVertexWithUV(x + w, y + h, this.zLevel, 1D, 1D); tessellator.addVertexWithUV(x + w, y + 0, this.zLevel, 1D, 0D); tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, 0D, 0D); tessellator.draw(); } To use this.mc.func_110434_K().func_110577_a( resource location of wanted texture ); drawTexture(this.xPosition+3, this.yPosition+3, 16, 16); Edit: Forgot to point out a few things. You do not need a new texture, just reuse your current one. The size field in drawTexture is the size you want it to be drawn not the size of the icon, the icon itself is scaled to this size.
July 12, 201312 yr Author that doesnt seem very usefull... i am using all the icons in the game for this and other mods may add some items that are compatible so i dont have any choice except to get this method working. if your going to add icons to the game then you are probably going to have to edit base classes. If you need any more help look at the source for ee3. lol? i know how to add icons to the game i just need to know how to draw an icon to a gui with the method that is given in the GuiScreen class. it has to work somehow i just dont know how. ... Do what I just told you. Make a new picture and put the icon there! Otherwise go look at the source for ee3. uhm... got a few reasons why i shouldnt do it like that. like a said earlier .... This will bind the blocks atlas this.mc.func_110434_K().func_110577_a(TextureMap.field_110575_b); This will bind the items atlas this.mc.func_110434_K().func_110577_a(TextureMap.field_110576_c); After binding one of those you can use an icon with drawTexturedModelRectFromIcon That only seems to work with the default blocks and items though, as it wouldn't draw the correct icon for any of my stuff. I figure there is another atlas for mod stuff but with nothing named I couldn't find it. So I wrote a simple work around. (its based off of drawTextureModelRectFromIcon) /** * Draws a texture at the given location, with the specified size * @param x Location X * @param y Location Y * @param w Draw Width * @param h Draw Height */ public void drawTexture(int x, int y, int w, int h) { GL11.glColor4f(1F, 1F, 1F, 1F); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0, y + h, this.zLevel, 0D, 1D); tessellator.addVertexWithUV(x + w, y + h, this.zLevel, 1D, 1D); tessellator.addVertexWithUV(x + w, y + 0, this.zLevel, 1D, 0D); tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, 0D, 0D); tessellator.draw(); } To use this.mc.func_110434_K().func_110577_a( resource location of wanted texture ); drawTexture(this.xPosition+3, this.yPosition+3, 16, 16); Edit: Forgot to point out a few things. You do not need a new texture, just reuse your current one. The size field in drawTexture is the size you want it to be drawn not the size of the icon, the icon itself is scaled to this size. it worked i was struggling with this problem for a while now so thx alot! http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
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.