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

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.

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

  • Author

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.

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

  • Author

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.

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

  • Author

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.

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

  • Author

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

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.