Solved Set Block To Colored Wool

Discussion in 'Plugin Development' started by Evonoucono, Aug 4, 2015.

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

    Evonoucono

    I am making a CTF plugin, because all the other ones don't do exactly what I want and Upon player death, I need a block of RED wool to spawn. I have figured out how to give colored wool to a player upon command, but that requires making a new ItemStack. I Cannot do this for a block that spawns in a set location, so how would I actually make a red Wool Block spawn instead of a white one. Besides this, everything else works. Here is what I currently have for the wool that spawns.
    Code:
    player.getLocation().getBlock().setType(Material.WOOL);
     
  2. @Evonoucono
    Try putting
    Code:
    , (short) "wool color id"
    in like so:
    Code:
    player.getLocation().getBlock().setType(Material.WOOL, (short) 1);
    I think that works not sure though. If not I have no clue ;)
     
  3. Offline

    Evonoucono

    Thanks for the reply, although I don't think it works. I've tried this, and I played around with it a lot, however it simply wants me to remove everything passed Material.WOOL ... Does anyone else have any other suggestions?

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  4. Offline

    Gater12

  5. Offline

    Butter1484

    The best thing to do would be something like
    Code:
    Block block = player.getLocation().getBlock();
    block.setType(Material.WOOL);
    block.setData(DyeColor.RED.getData());
     
  6. Offline

    mine-care

    @Butter1484 @Gater12 @Evonoucono or use Block#setTypeAndData to spare one line :p

    Also dont be afraid of deprecation in certain cases, Read docs to find alternatives if there are any. Otherwise there is no option but to use the deprecated methods.
     
  7. Offline

    Evonoucono

    Thanks Butter1484, and mine-care! It worked!
     
Thread Status:
Not open for further replies.

Share This Page