Posted November 6, 20204 yr Given a ItemStack from player.getItemStackFromSlot(EntityEquipmentSlot.FEET); or any slot how to test for a given color, or print the color thanks!
November 7, 20204 yr 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().
November 7, 20204 yr Author 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
November 7, 20204 yr Author 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.