Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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

  • Author

Sorry for me being stupid, but can you show me how to do one? Because in 1.7.10 I don't know how to do that... Again sorry if that sounds stupid. :-\

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.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.