Jump to content

Recommended Posts

Posted

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]

Posted

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/

Posted

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]

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.