Jump to content

Recommended Posts

Posted
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().

Posted

do you know how color codes work? I have blue boots and it has a nbt tag display.color = 3949738. Boots are blue. How do i get that in runtime? is there any class or enum or dyes.getColorFromCode(3949738) // blue

Posted

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);
	}

 

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.