Jump to content

Getting texture from an item as an image and exporting it (1.18.2)


Greenem

Recommended Posts

I have and Item/ItemStack and I need to get it's texture as an usual image. (I'm quite new to modding)
I tried doing random stuff with ResourceLocation, ItemRenderer and BlockRenderDispatcher, but didn't succeed. I know that now it's all models and not textures (and some other info), but I'm just too new to this to know what ways to do this exist
Can you help me?

Link to comment
Share on other sites

Thanks, but I sill don't understand some details
I tried your way and created this:

Player p = Minecraft.getInstance().player;
Item item = p.getInventory().getSelected().getItem();
Block b = Block.byItem(item);
Minecraft.getInstance().getItemRenderer().getModel(item.getDefaultInstance(), p.getLevel(), p, 1).getQuads(b.defaultBlockState(), Direction.NORTH, new Random()).get(0).getSprite()

But what are the 4th argument in getModel(...) and 3rd argument in getQuads(...)? Am I using all of this in any supposed way? (I just don't know what to put in the arguments) Anyway, this (somehow) gives me the TextureAtlasSprite, but how can I save it to png file?

Edited by Greenem
Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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