Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

*SOLVED* rendering item icon to bitmap


Recommended Posts



I'm trying to make a little util mod to document all loaded recipes. Currently, I'm stuck at trying to save item icons as images.


I'm thinking of rendering icon to FBO buffer, and then saving it to bitmap. I'm not that good with opengl, so I've tried something simple like that:




Used like:

for (ItemStack item : ItemList.items)


But, obviously it doesn't work - the image is saved, but only the background (glClear) is rendered - the icon is not visible.

Is it the right approach? Any advices on how could I make it work?




Thanks in advance for your time!  :)



e: if anyone's wondering, I'm using mc 1.6.4.


e2: this works fine when called in tick end after world is loaded:

    static protected void renderItem(ItemStack itemStack)
        if (Tessellator.instance.isDrawing)
        GL11.glClearColor(1, 1, 1, 0);
        drawItemStack(itemStack, 0, 0, "overlay");

        String directory = "C:/test/";
        ScreenShotHelper.saveScreenshot(new File(directory), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
        moveImageTo(new File(directory + itemStack.getDisplayName() + ".png"), directory);

    protected static RenderItem renderItem = new RenderItem();

    static private void drawItemStack(ItemStack par1ItemStack, int par2, int par3, String par4Str)
        renderItem.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), par1ItemStack, par2, par3);
        //renderItem.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, this.mc.getTextureManager(), par1ItemStack, par2, par3 - (this.draggedStack == null ? 0 : , par4Str);


(moveImageTo just renames the file, and the window needs to have desired icon size)




import net.minecraft.client.Minecraft;
import net.minecraft.util.ScreenShotHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import java.io.File;
import java.io.FilenameFilter;

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.

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 Privacy Policy.