Jump to content

(Solved) [1.9] How to Programatically Color Leather Armor items?


Recommended Posts

Posted

My question is pretty simple (I think). I want to drop some armor pieces that are pre-colored ... as they'd look if a player dyed them in game. I've found sites that list the various hex color codes for dyes but so far haven't found any docs or examples on how to apply to leather armor items programatically in a Forge mod. Here's the section of code I need help expanding to make this happen (if it's even possible?):

 

- - - - - - - - - - - - - - - - - - - - -

ItemStack bluePants = new ItemStack(Items.leather_leggings, 1);

// *** How can I color these pants blue before dropping? *** //

event.getEntityLiving().entityDropItem(bluePants, 0);

- - - - - - - - - - - - - - - - - - - - -

 

BTW - I tried a few searches here (and general Google search) but so far haven't found an existing thread asking specifically what I'm looking for - but my apologies if this info has already been asked/documented. Either my search strings are using the wrong words or maybe this just isn't possible? Feel free to just send me to a Wiki/Documentation page if one exists ... but thanks in advance for whatever help anyone can provide!

Posted

That Wiki didn't really help but it could be that I'm just far too "beginner" with MC mod dev to see the connection (?). In any case after more searching the web I eventually found something working. I'm not sure if it's total noob way of doing it but it is working in game now.

 

Here's what I ended up using in case anyone else ever has the same need/question as I did:

 

ItemStack bluePantStack new ItemStack(Items.leather_leggings, 1);
((ItemArmor) bluePantStack .getItem()).setColor(bluePantStack , 2437522);
event.getEntityLiving().entityDropItem(bluePantStack , 1);	

 

Color codes found here: https://github.com/FallenMoonNetwork/CanaryLib/blob/master/src/main/java/net/canarymod/api/DyeColor.java

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.