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

How would I make and item that I could set the color with a hex value. (Like leather armor does.).

 

I have a basic item using a gray scale texture what would I need to add.

 

Notice! I have looking in ItemArmor and at how grass does it but no luck with it.

 

Not asking for the code just a step in the right direction.

  • Author

That's the thing that does nothing even if you tell it to return a hex code no matter what.

Odd, because it works for me:

 

public class ItemCrossbowRepater extends Item
{
//A weapon that will use the player's stamina reserves to fire weak arrows
//It has different functions with different effects
//Will be reworked hard when a proper leveling system is created
//See notes on this.
private IIcon[] icons = new IIcon[2];

public ItemCrossbowRepater()
{
	setFull3D();
	setMaxDamage(0);
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister ir) 
{
	/*for (int i = 0;i < textures.length; i++)
	{
		textures[i] = ir.registerIcon(Rot.MODID+":"+"relicLife_"+i);
	}*/
	icons[0] = ir.registerIcon(Rot.MODID+":"+"cbr");
	icons[1] = ir.registerIcon(Rot.MODID+":"+"cbr_overLay");
}

@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
{
	if (par2 == 0)return 0xFFFFFF;
	else
	{
		switch (par1ItemStack.getItemDamage())
		{
			case 0:
				return 0xFFFFFF;
			case 1:
				return 0xFF622E;
			case 2:
				return 0x4DC9FF;
			case 3 :
				return 0xFFE263;
			default:
				return 0xFFFFFF;
		}
	}
}

@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
	return true;
}

@Override
public int getRenderPasses(int metadata)
{
	// TODO Auto-generated method stub
	return 2;
}

@Override
public IIcon getIcon(ItemStack stack, int pass)
{
	// TODO Auto-generated method stub
	return icons[pass];
}

 

Maybe it only works with multiple render passed items?

  • Author

I will post code when I get back from school. Maybe its because I don't have an over lay.

@Override

@SideOnly(Side.CLIENT)

public void registerIcons(IIconRegister ir)

{

                icons = new IIcon[2];

icons[0] = ir.registerIcon(Main.MODID+":"+"ingot");

icons[1] = ir.registerIcon(Main.MODID+":"+"ingot");

}

 

define the array as the size you want also I wonder if you can trick it by not using two by overriding

 

@Override

public int getRenderPasses(int metadata)

{

return 1;

}

 

so it only does one pass, that way it will most likely be less hungry for double rendering for no reason

  • Author

Still getting on NPE on  icons[0] = ir.registerIcon(Main.MODID+":"+"ingot");

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.