Jump to content

[1.7.10] dynamicly coloring items like leather armor does.


Chibill

Recommended Posts

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.

Link to comment
Share on other sites

there is a method for items called "getColorFromItemStack"

 

you then return the hex value you want (or the decimal conversion if it, but I find it easier to just use 0xFFFFFF or the likes)

 

the two params are itemstack and renderpass

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.