Posted April 24, 201510 yr I was wondering how I could get an item's icon to display in a GUI. (Or a fake slot would work too, but I don't know how to do that either.) Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
April 24, 201510 yr Warning: This is only for 1.7.10. I haven't figured out what the equivalent for 1.8 is yet. You may want to draw the texture of an Item in a custom GuiScreen. Items don't directly have a ResourceLocation for their texture. Instead, they have an IIcon object which holds the UV-coordinates of the texture on a giant image which holds all the Item textures. The ResourceLocation is located at TextureMap.locationItemsTexture. If you want to use this in a GUI, you have to get the IIcon of the Item first, bind the TextureMap.locationItemsTexture, and then call the drawTexturedModelRectFromIcon() method to draw the IIcon of the item. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
April 24, 201510 yr Author Warning: This is only for 1.7.10. I haven't figured out what the equivalent for 1.8 is yet. You may want to draw the texture of an Item in a custom GuiScreen. Items don't directly have a ResourceLocation for their texture. Instead, they have an IIcon object which holds the UV-coordinates of the texture on a giant image which holds all the Item textures. The ResourceLocation is located at TextureMap.locationItemsTexture. If you want to use this in a GUI, you have to get the IIcon of the Item first, bind the TextureMap.locationItemsTexture, and then call the drawTexturedModelRectFromIcon() method to draw the IIcon of the item. So, something like this? protected void guiDrawIcon(Item item, int x, int y) { Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); IIcon icon = item.getIconFromDamage(0); GL11.glEnable(GL11.GL_BLEND); this.drawTexturedModelRectFromIcon(x, y, icon, 16, 16); GL11.glDisable(GL11.GL_BLEND); } Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
April 24, 201510 yr I think so, yeah. Did it work? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
April 24, 201510 yr If this doesn't work you can make an fake slot. Just simply create your own slotclass (extending Slot) and set the "isItemValid()" and "canTakeStack()" to false.(not sure if these are the exact methodes, but you'll have to add the right one anyway if you extend the Slot class) Projects: Discontinued: - N2ConfigAPI - Meachanical Crafting Table Latest: - CollectionUtils Coöperations: - InGameConfigManager
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.