Posted December 14, 20177 yr 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
December 14, 20177 yr 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.
December 14, 20177 yr Author 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.
December 14, 20177 yr Author 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 December 14, 20177 yr by Matt2017
December 14, 20177 yr 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.
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.