Posted April 23, 201312 yr Im trying to draw an icon in a custom gui. but it doesnt work properly. instead of drawing the icon it draws a part of the gui. this is the code that im using. FontRenderer fontrenderer = par1Minecraft.fontRenderer; par1Minecraft.renderEngine.bindTexture("/mods/legendz/textures/gui/npcdialog.png"); boolean var1 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; this.drawTexturedModalRect(xPosition, yPosition, 144, 0, width, height); Icon var2 = reward.getIconIndex(); System.out.println(var2.getIconName()); GL11.glPushMatrix(); this.drawTexturedModelRectFromIcon(0, 0, var2, 16, 16); GL11.glPopMatrix(); i cant figure out what is wrong with it. some help would be greatly apreciated; http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
April 23, 201312 yr Author Im trying to draw an icon in a custom gui. but it doesnt work properly. instead of drawing the icon it draws a part of the gui. this is the code that im using. FontRenderer fontrenderer = par1Minecraft.fontRenderer; par1Minecraft.renderEngine.bindTexture("/mods/legendz/textures/gui/npcdialog.png"); boolean var1 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; this.drawTexturedModalRect(xPosition, yPosition, 144, 0, width, height); Icon var2 = reward.getIconIndex(); System.out.println(var2.getIconName()); GL11.glPushMatrix(); this.drawTexturedModelRectFromIcon(0, 0, var2, 16, 16); GL11.glPopMatrix(); i cant figure out what is wrong with it. some help would be greatly apreciated; http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
April 23, 201312 yr Any time I need to draw an icon, or anything really, I just draw it off of a sprite sheet. I bind the texture like you do and use drawTexturedModalRect(). You just specify where to draw it, and where on the sprite sheet the part you want to draw is and how big it is. Make sure the file is 256x256 or a multiple of that (E.g. 512x512.) The position and size is also assuming that your sheet is 256x256, so position (128, 0) is always the top middle. If you don't want to do it that way (I'd recommend you do because you don't have to put your icons in the mods folder and you can put everything in one file.), you are probably just not getting the path right. I haven't done icons the way you tried, as I said, but I don't think you're supposed to put icon files in your mods folder. I'd recommend you make a gui folder right next to your code and reference it in there. A path like "/legendz/gui/npcdialog.png" should work fine. http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img] I make games, minecraft mods/plugins, and some graphic art. Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.
April 23, 201312 yr Any time I need to draw an icon, or anything really, I just draw it off of a sprite sheet. I bind the texture like you do and use drawTexturedModalRect(). You just specify where to draw it, and where on the sprite sheet the part you want to draw is and how big it is. Make sure the file is 256x256 or a multiple of that (E.g. 512x512.) The position and size is also assuming that your sheet is 256x256, so position (128, 0) is always the top middle. If you don't want to do it that way (I'd recommend you do because you don't have to put your icons in the mods folder and you can put everything in one file.), you are probably just not getting the path right. I haven't done icons the way you tried, as I said, but I don't think you're supposed to put icon files in your mods folder. I'd recommend you make a gui folder right next to your code and reference it in there. A path like "/legendz/gui/npcdialog.png" should work fine. http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img] I make games, minecraft mods/plugins, and some graphic art. Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.
April 23, 201312 yr Author The way i handle my icons works fine for me. and i want to draw a 18*18 image from the npcdialog.png and that works fine to. The only problem i have is that the icon wont draw. and since i want to draw the icon that is used by the ItemStack called reward on the screen i cant use a 256 by 256 texture. that would be way to much work to do and unnessecary since there is a better way. now the problem im experiencing is that something is drawn but not from the Icon given by the reward field. i printed the icon name and it does give me the corresponding names for the icons. my only guess is that it draws it from the texture binded by the minecraft render engine. and i dont know how to bind the Icon to the render engine and if that is rigth a good solution to this problem. http://www.minecraftforum.net/topic/1937703-162smpforge-pet-mastery-hatch-level-battle/
April 23, 201312 yr Author The way i handle my icons works fine for me. and i want to draw a 18*18 image from the npcdialog.png and that works fine to. The only problem i have is that the icon wont draw. and since i want to draw the icon that is used by the ItemStack called reward on the screen i cant use a 256 by 256 texture. that would be way to much work to do and unnessecary since there is a better way. now the problem im experiencing is that something is drawn but not from the Icon given by the reward field. i printed the icon name and it does give me the corresponding names for the icons. my only guess is that it draws it from the texture binded by the minecraft render engine. and i dont know how to bind the Icon to the render engine and if that is rigth a good solution to this problem. 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.