Jump to content

[1.12.2] Get Icon Image of an Item


Matt2017

Recommended Posts

I'm trying to get a BufferedImage of an Item's 2d icon. I did my research on Google and I found getIconFromDamage, but this method no longer exists. I tried item.getRegistryName but I don't know how to get the png file since some names are different(e.g. minecraft:wheat_seeds and assets/minecraft/textures/items/seeds_wheat.png).

Any help would be appreciated:D

Link to comment
Share on other sites

Items have models, and models have one or more textures. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Draco18s said:

Items have models, and models have one or more textures. 

Thanks for replying.

 

I wrote this piece of code:

IModel model = ModelLoaderRegistry.getModel(new ResourceLocation("minecraft:item/" + itemStack.getItem().getRegistryName().getResourcePath()));
ResourceLocation resourceLocation = (ResourceLocation) model.getTextures().toArray()[0];
InputStream inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(resourceLocation.getResourceDomain() + ":textures/" + resourceLocation.getResourcePath() + ".png")).getInputStream();
BufferedImage image = ImageIO.read(inputStream);

 

I successfully extracted the icon, but I'm not sure if this approach also works on custom textures.

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Unfortunately you cannot make your life that easy.

  • Models might not have a physical file on disk.
  • Textures might not have a physical file on disk.

To get the model for any ItemStack use Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(...). This will give you an IBakedModel. You can then use IBakedModel::getParticleTexture to get the particle texture (which is usually accurate). If you want more accurate information, you'll need to inspect the BakedQuads of the model (IBakedModel::getQuads), and then use BakedQuad::getSprite to get each individual quad's texture.

Thanks! Now I've got the 2d icons. How can I get 3d icons by the way?

Edited by Matt2017
Link to comment
Share on other sites

I think he means the baked item model. Which wound be the IBakedModel instance. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://codepen.io/Smart-Cast-Official/pen/ExGQRoV https://club.vexanium.com/post/https-www-reddit-com-r-ncaalivereddit-comments-16q5oha-f0-9d-9a-81-f0-9d-97--650ef5be1e80647e3eeb9ca8 https://codepen.io/Smart-Cast-Official/pen/JjwpZvR
    • https://www.reddit.com/r/boxon2joe/comments/16q4lvd/𝚁edditstreams_joe_joyce_vs_zhilei_zhang_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4okk/𝚁edditstreams_zhilei_zhang_vs_joe_joyce_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4qfg/crackstreamsjoe_joyce_vs_zhilei_zhang_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4rzs/heres_how_to_watch_joe_joyce_vs_zhilei_zhang_2/ https://opensea.io/collection/dgfdggg https://ctxt.io/2/AABQBWOVEQ http://pastebin.falz.net/2503846 https://www.pastery.net/hjetpj/ https://glot.io/snippets/gozv4sksja https://jsfiddle.net/9p0dgu8x/ https://pastebin.freeswitch.org/view/c7738ab8 https://telegra.ph/dfgfdgfd-09-23 https://textbin.net/pqneaxhshc https://rentry.co/ru5cr https://jsitor.com/ZRmFaXgr1 https://controlc.com/590b0f4c9 https://pastebin.com/aBDWyPgp https://pastelink.net/4bmst26a https://paiza.io/projects/PAzRqXayCcDpVwevNqKTqA https://codepen.io/awal-sardar/pen/XWoZYbL https://paste2.org/n0d1BVKg https://forum.contentos.io/topic/276632/dfdfddd https://club.vexanium.com/question/https-www-reddit-com-r-boxon2joe-comments-16q4lvd-f0-9d-9a-81edditstreams-j--650eeb680c57cce3a94a311d https://www.bankier.pl/forum/temat_fdvcxffdfd,62611793.html https://www.wowace.com/paste/b7037d3d https://paiza.io/projects/NMcTLwv22mIjbccKmjcOSA https://forum.contentos.io/topic/276640/sadfcsa-fc-sa https://club.vexanium.com/question/https-www-reddit-com-r-boxon2joe-comments-16q4lvd-f0-9d-9a-81edditstreams-j--650eebed98849ea70bcd7f2d https://www.wowace.com/paste/60089ab3 https://codepen.io/sexybutpertv/pen/xxmYzZb https://community.thermaltake.com/index.php?/topic/357848-sad-asd-as/ https://forums.minecraftforge.net/topic/126320-sad-asdf-sadf-sd/ https://controlc.com/822568ff https://www.pastery.net/nkfcve/ https://jsfiddle.net/sadiakhan/2y5cx4Lu/1/ https://paste2.org/7c65nmPD https://paste.intergen.online/view/edbc3162 https://glot.io/snippets/gozv9pox2q https://pastelink.net/oazofzh3 https://www.bankier.pl/forum/temat_asdx-assda,62611811.html https://www.wowace.com/paste/cd8464cf https://www.muthead.com/forums/mut-discussion/336044-joe_joyce_vs_zhilei_zhang_2_live-reddit/ https://www.pastery.net/ncpwvq/ http://pastebin.falz.net/2503848 https://pastebin.com/e0MqMV1i
    • https://www.reddit.com/r/boxon2joe/comments/16q4lvd/𝚁edditstreams_joe_joyce_vs_zhilei_zhang_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4okk/𝚁edditstreams_zhilei_zhang_vs_joe_joyce_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4qfg/crackstreamsjoe_joyce_vs_zhilei_zhang_2_live/ https://www.reddit.com/r/boxon2joe/comments/16q4rzs/heres_how_to_watch_joe_joyce_vs_zhilei_zhang_2/  
    • https://club.vexanium.com/post/https-www-reddit-com-r-ncaafreditw4-comments-16q3tkg-f0-9d-9a-81edditstream--650ee3124fb9af2ddeb8223d https://www.bitsdujour.com/profiles/NyikSV https://codepen.io/Smart-Cast-Official/pen/PoXQeXp https://jsfiddle.net/0jmc9xvr/ https://notes.io/qEjih https://www.click4r.com/posts/g/12048983/ https://yamcode.com/untitled-82797 https://paiza.io/projects/ycxhnoOyQ4cGsya-C57dYQ?language=php
    • I have made a server and am trying to use the mods from "Medieval Minecraft [FORGE] 1.19.2 MMC3", but am getting this error after fixing a few other easy ones. I can't find anything relevant after around 1 hour of searching, so has anyone got any suggestions?
  • Topics

×
×
  • Create New...

Important Information

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