Colored Wool?

Discussion in 'Plugin Development' started by evilmidget38, May 9, 2012.

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

    evilmidget38

    How can I set a block to a specific color of wool(e.g.g red)? Should be a pretty basic question, but I just can't seem to figure out how.
     
  2. Offline

    Niq

  3. Offline

    Father Of Time

    You set the data value in the block state, not the metadata.

    Code:
    ItemStack redwool = new ItemStack( Material.WOOL, 1, (byte)4 );
    player.getInventory().addItem( redwool );
    you change the byte variable to change the color using the color data from the link Niq provided above.

    Hope this helps!
     
  4. Offline

    desht

    The Bukkit DyeColor class is also handy:
    PHP:
    ItemStack redwool = new ItemStack(Material.WOOL1DyeColor.RED.getData());
     
    CorrieKay and Father Of Time like this.
  5. Offline

    Father Of Time

    Smart tip, I didn't think of doing this; I always have to Google "Minecraft color codes" each time I want to set wool color.

    Thanks for sharing your shortcut!
     
    desht likes this.
  6. Offline

    evilmidget38

    Thanks, but I also need to know how I set a Block(non-item, just any old block in the world) to a specific color of wool. I know how to set it to wool, and have done so, but I've got no clue how to change the color.
     
  7. Offline

    desht

    In a similar way:
    PHP:
    block.setTypeIdAndData(35DyeColor.RED.getData(), true);
    // or
    block.setType(Material.WOOL);
    block.setData(DyeColor.RED.getData());
     
    PDKnight, Jozeth and evilmidget38 like this.
  8. Offline

    evilmidget38

    Once again, thanks.
     
  9. Well I already made a plugin called ParagonWool. My source is in there. See link in my sig.
     
Thread Status:
Not open for further replies.

Share This Page