Help with finding if a player is holding red dye.

Discussion in 'Plugin Development' started by potatofarms, Aug 14, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    I cannot seem to figure out what the code would be for doing this. I am currently using
    if(p.getItemInHand().getType().equals(DyeColor.RED)) {
        p.sendMessage(ChatColor.LIGHT_PURPLE + "It works");
    But it doesn't work. Am I doing this wrong?
  2. You first have to check if the material equals Material.WOOL, and the Type is a material not a DyeColor.
  3. Dyes are stored in the INK_SACK item actually and the colors are in the data/durability/damage (same thing) value.

    ItemStack item = p.getItemInHand();
    if(item.getType() == Material.INK_SACK && item.getDurability() == 15)
        // player is holding bonemeal
    potatofarms likes this.
  4. Offline


    So I changed it to Material.WOOL, but what is the code for the dye? Material.ROSE_RED doesn't exist, and Material.RED_ROSE is for a red rose. I only want to check if they have the red dye, not wool, or red wool. I may have misunderstood what you were trying to say, if I was please let me know, and I apologize in advanced.

    So I searched the damage value for red dye, and it is 1 so I will now try
    "if(item.getType() == Material.INK_SACK && item.getDurability() == 1)" and see if it works.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 27, 2016
  5. Oh that way, than look at the post above this one xD
  6. Offline


    Sweet! Thanks Digi, it works perfectly now. :)
    blackwolf12333 likes this.
Thread Status:
Not open for further replies.

Share This Page