Jump to content

Recommended Posts

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;
}

}

Posted

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.

Posted

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

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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