Jump to content

get leather armor [dyed] color? [latest version]


ciroreed

Recommended Posts

35 minutes ago, ciroreed said:

Given a ItemStack from player.getItemStackFromSlot(EntityEquipmentSlot.FEET); or any slot

how to test for a given color, or print the color

 

thanks!

You could check if the item is an instance of IDyeableArmorItem, and if so, use IDyeableArmorItem.getColor().

Link to comment
Share on other sites

My use case is the following. In order to use an item I have to check that the player is wearing a (dyed) blue leather armor

 

ok, this can be closed. Just to share it:

 

@Override
	public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
		if(world.isRemote) return super.onItemRightClick(world, player, hand);

		ItemStack itemStackBoots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
		if(itemStackBoots.isEmpty()) return super.onItemRightClick(world, player, hand);

		int colorValue = itemStackBoots.getTagCompound().getCompoundTag("display").getInteger("color");

		for (EnumDyeColor color : EnumDyeColor.values()) {
			if(colorValue == color.getColorValue()) {
				out.println(color.getName());
			}
		}

		return super.onItemRightClick(world, player, hand);
	}

 

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.

Announcements



×
×
  • Create New...

Important Information

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