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

I have a custom IItemRenderer working, and need to add the following functionality:

 

First render the default icon for that item.

Then render the icon of a block based on the damage value of the item

 

So it would render my item's icon, then maybe the icon for dirt on top as an overlay.

 

I think my biggest question is how to bind the correct texture sheet of the overlay'd block so I can pass it to renderItem.renderIcon

 

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return item.itemID == Items.arcaneTemplate.itemID;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

Icon icon = item.getIconIndex();
renderItem.renderIcon(0, 0, icon, 16, 16);

switch(item.getItemDamage()) {
case 1:			
	// render Dirt overlay
	break;

case 2:
	// render Cobble overlay
	break;
}

}

  • Author

When I do

 

icon = Block.dirt.getIcon(1, 1);

renderItem.renderIcon(0, 0, icon, 16, 16);

 

it appears to be rendering half of the lapis icon.

When I do

 

icon = Block.dirt.getIcon(1, 1);

renderItem.renderIcon(0, 0, icon, 16, 16);

 

it appears to be rendering half of the lapis icon.

 

Item icons use a different sprite sheet from block icons.

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.

  • Author

Item icons use a different sprite sheet from block icons.

 

Exactly, hence my original question how to I get the correct sheet for the dirt block's item icon?

  • Author

Hi

 

If your Item's custom renderer uses an icon from the block texture map, make sure that Item.getSpriteNumber() returns 0, otherwise the tessellator will render using the item texture map, i.e. the wrong icons will be used.

 

See also

http://greyminecraftcoder.blogspot.com.au/2013/09/custom-item-rendering-using.html

 

-TGG

 

Not sure how I can do this - I need to render my item's icon first, then render a block icon over top.

 

I can confirm that yes if I override that method for my item , then the block icons work fine, but my item's icon is then not rendered correctly :)  Catch 22

Hi

 

In that case, check out Item.renderItem, in particular this bit

 

        IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(par2ItemStack, type);
        if (customRenderer != null)
        {
            texturemanager.func_110577_a(texturemanager.func_130087_a(par2ItemStack.getItemSpriteNumber()));
            ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksInstance, par1EntityLivingBase, par2ItemStack);
        }

 

(func_110577_a and func_130087_a are hopefully called something meaningful in yours)

 

i.e. perhaps it will be enough to call

            texturemanager.func_110577_a(texturemanager.func_130087_a(0));

and

            texturemanager.func_110577_a(texturemanager.func_130087_a(1));

 

before your two custom renders.

 

-TGG

 

 

 

 

 

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

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.