Jump to content

Recommended Posts

Posted

Hi!

 

I have an item, basically a special book. It'll be the guide for my mod. I created a renderer for it, because I want it to render with a little particle-like icon behind it. But, the problem is: in certain cases, the renderer just acts weird.

 

Let me show you some pictures:

 

With blocks on any GUI it is fine...

IN20Ju2.png

 

See the particle-like icons? They are small, but eh...

SP70FvP.png

 

BUT, if I put an item (e.g a redstone) next to it on the left, it freaks out.

vwzOcV4.png

 

BUT, if I put an item next to it on the RIGHT it's still cool.

beixN8G.png

 

And, this is not for just this, item... I have more stuff with multiple layers rendered together, and in these cases all of them freaks out.

 

Here's my code:

 

IItemRenderer:

    private ItemGuide guide;
    private RenderItem renderItem = RenderItem.getInstance(); //UNUSED!

    @Override
    public boolean handleRenderType(ItemStack item, ItemRenderType type)
    {
        return type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY;
    }

    @Override
    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
    {
        return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING;
    }

    @Override
    public void renderItem(ItemRenderType type, ItemStack item, Object... data)
    {
        if(item.getItem() instanceof ItemGuide)
            guide = (ItemGuide) item.getItem();

        switch(type)
        {
            case ENTITY:
                IIcon si = item.getIconIndex(); //The book icon
                IIcon pi = guide.getParticleIcon(); //The particles, got by a special method specified in the item class.

                if(!item.isOnItemFrame())
                {
                    GL11.glTranslatef(-0.5F, 0, 0);
                    ItemRenderer.renderItemIn2D(Tessellator.instance, pi.getMaxU(), pi.getMinV(), pi.getMinU(), pi.getMaxV(), pi.getIconWidth(), pi.getIconHeight(), 1.0F / 16.0F);
                    ItemRenderer.renderItemIn2D(Tessellator.instance, si.getMaxU(), si.getMinV(), si.getMinU(), si.getMaxV(), si.getIconWidth(), si.getIconHeight(), 1.0F / 16.0F);
                }
                else
                {
                    GL11.glTranslatef(0.5F, -0.1F, 0);
                    GL11.glRotatef(180.0F, 0, 1, 0);
                    ItemRenderer.renderItemIn2D(Tessellator.instance, pi.getMaxU(), pi.getMinV(), pi.getMinU(), pi.getMaxV(), pi.getIconWidth(), pi.getIconHeight(), 1.0F / 16.0F);
                    ItemRenderer.renderItemIn2D(Tessellator.instance, si.getMaxU(), si.getMinV(), si.getMinU(), si.getMaxV(), si.getIconWidth(), si.getIconHeight(), 1.0F / 16.0F);
                }
                break;
            case INVENTORY:
                si = item.getIconIndex();
                pi = guide.getParticleIcon();

                glScalef(16, 16, 16);
                ItemRenderer.renderItemIn2D(Tessellator.instance, pi.getMinU(), pi.getMaxV(), pi.getMaxU(), pi.getMinV(), pi.getIconWidth(), pi.getIconHeight(), 1.0F / 16.0F);
                ItemRenderer.renderItemIn2D(Tessellator.instance, si.getMinU(), si.getMaxV(), si.getMaxU(), si.getMinV(), si.getIconWidth(), si.getIconHeight(), 1.0F / 16.0F);
                break;
            default:
                break;
        }
    }

 

I'm using ItemRenderer.renderItemIn2D, because that renders with thickness. So, renderItem is unused!

Other cases, EQUIPPED and EQUIPPED_FIRST_PERSON I'm using the default ones, because I want the particles only render in cases ENTITY and INVENTORY.

 

Anybody help?

Posted

Dont use a IItemRenderer, just use a normal multi-layer item...

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

You need to override

Item#requiresMultipleRenderPasses

to return

true

and

Item#getIcon(ItemStack stack, int pass)

to return the particle icon on pass 0 and the book icon on pass 1.

 

Look at the vanilla overrides of

Item#getIconFromDamageForRenderPass

for examples of multi-layer items.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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