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.

[1.7.2][SOLVED]getIcon not setting the icon for the item in inventory

Featured Replies

Posted

I never expected I would ever have to ask for help with item icons I thought I had them figured out. Then I tried to do something new and here I am...

 

Until recently I have been using getIconFromDamage() whenever I need to be able to switch between icons e.g.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
if (par1 == 0)
	return itemIcon0;
else if (par1 == 1)
	return itemIcon1;
else
	return itemIcon2;
}

But then I switched to nbt for storing item data which obviously broke this so i switched to

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
	return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
	return itemIcon1;
else
	return itemIcon0;
}

But for some reason this dosnt work properly the item renders correctly in the players hand but in the inventory it tries to use the default icon (itemIcon) which in this case is null.

 

Can anyone tell me what im doing wrong?

I am the author of Draconic Evolution

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.