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

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!

  • Author

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

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.