FunshineX Posted October 23, 2013 Posted October 23, 2013 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; } } Quote
GotoLink Posted October 23, 2013 Posted October 23, 2013 You can get a block Icon with Block.blocksList[id].getIcon(int,int). Quote
FunshineX Posted October 24, 2013 Author Posted October 24, 2013 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. Quote
Draco18s Posted October 24, 2013 Posted October 24, 2013 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. Quote 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.
TheGreyGhost Posted October 25, 2013 Posted October 25, 2013 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 Quote
FunshineX Posted October 28, 2013 Author Posted October 28, 2013 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? Quote
FunshineX Posted October 28, 2013 Author Posted October 28, 2013 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 Quote
TheGreyGhost Posted October 28, 2013 Posted October 28, 2013 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 Quote
Recommended Posts
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.