Jump to content

Hook for getIconIndex(ItemStack par1ItemStack)


Recommended Posts

Posted

Currently Item.getIconIndex(ItemStack par1ItemStack) is final and calls another function (which is not) with a lower-typed parameter: getIconFromDamage(int par1).

 

This means that I can't use NBT data to override the inventory icon, only the held model icon.

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

Im pretty sure you can. *looks at all the other mods out there that have item stack senstive icons* Cant think off the top of my head but ya, pretty sure you can.

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

Im pretty sure you can. *looks at all the other mods out there that have item stack senstive icons* Cant think off the top of my head but ya, pretty sure you can.

 

public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

(which calls

public Icon getIcon(ItemStack stack, int pass)

and am currently overriding) doesn't work.

 

The only other functions available are

public Icon getIconFromDamageForRenderPass(int par1, int par2)

and

getIconFromDamage(int par1).

which lacks the ItemStack.

 

Oh look:

 

//ItemStack.java
public Icon getIconIndex()
    {
        return this.getItem().getIconIndex(this);
    }

 

That calls the function I'm asking about.  That's the only method on ItemStack that returns an Icon.

 

I'd hazard a guess that those other mods wrote a custom renderer for their item, which would be unnecessary if the Item class didn't have this function as final.

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

What exact code path are you looking at, there are many different places where icons are grabbed.

 

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

Solution was to render in pass 2 (which is not obvious, but anyway).

 

What exact code path are you looking at, there are many different places where icons are grabbed.

 

I want the item icon when it appears in inventories.  The only place an ItemStack gets its icon is the quoted function, which calls back to the finalized function in Item.java.

 

I checked out all the other variants of getIcon in the Item class, as I'd said, but two of them don't take the item stack, two of them only cause the item to render in 3D with the indicated icon (the first passing its params to the second), and the last method is final.  There aren't any others.

 

So I'm not sure what you're question is.

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

My question is.

What is the exact stack, that is being called through, that makes you want this function to not be final.

Yes I understand there is a function in ItemStack that calls that final function.

But what calls that?

And what calls that?

And what calls that?

...

WHY is that section of code being called. WHY does the change need to be done? Can the change be done in any other way?

You should have a intimate understanding of what you're asking before you ask it.

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

Its called by

renderItemIntoGUI

in RenderItem.

 

There is one other function with the same name that also calls this funciton, passing an extra parameter

 

doRenderItem

also calls this function.

 

renderItemIntoGUI

also handles mutliple-pass rendering which calls the other function, so while there is a way to render the NBT data driven icon through the multiple-pass renderer, it should not be needed.  It's a single icon that needs to be rendered once.

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
@Override
    public boolean requiresMultipleRenderPasses()//kinda strange , but don't worry...
    {
        return true;
    }
@Override
public int getRenderPasses(int metadata)//we can save the other passes, actually
    {
        return 1;
    }
@Override
public Icon getIcon(ItemStack stack, int pass){//icons from NBT here...
}

Posted

//kinda strange :P, but don't worry...

 

That's kinda why I made the suggestion. width=15 height=15http://forums.dumpshock.com/style_emoticons/default/sarcastic.gif[/img]

It's completely bonkers for a protected method ("I'm sorry, this function does something absolutely critical to the functioning of the program that you can't change it") only calls a non-protected ("change this at your whim") method.

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.

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.