Help setting blocks to different types of flowers.

Discussion in 'Spigot Plugin Development' started by Fearmig, Jul 5, 2015.

  1. I need some help with setting a block to different flowers. I realize there is a Material for yellow flower and red flower and I also know how to create an ItemStack of the correct type but actually setting a block I just couldn't figure out. Anybody possibly able to give me a hand?
  2. Code (Text):

    Block block = new Block(); //initialize the block here
    block.setType(Material.Bedrock); //Sets the block to bedrock (change that to what you wish)
    EDIT: I misunderstood the question, ignore what I said.
    #2 DuYan, Jul 5, 2015
    Last edited: Jul 5, 2015
    • Funny Funny x 1
  3. sothatsit


  4. sothatsit


    You can't instantiate Block. He is asking for different types of flowers, not just the base ones, which requires data values.
    • Agree Agree x 1
  5. using the byte value you can change the type of flower this is for a blue orchid, this will create an itemstack for that item ->

    Code (Text):

    ItemStack flower = new ItemStack(Material.RED_ROSE, 1, (short) 1);
    taken from here ->
  6. sothatsit


    This is correct for ItemStack's but for blocks you have to use Block.setType and Block.setData.


    Block block = /* get block */;
    block.setData((byte) 1);
  7. Was my post misleading (i ask because i should change if folks don't understand) I know the Material I'm just not sure how to change the material to contain a damage value so that it may contain different color flowers?
    So depreciated is the only way to go?

    I literally said in my initial post that i know how to create the itemStack version :/
  8. Sorry I misread that part! you said you know the "material" not "itemstack" so it wasnt really that clear.
  9. sothatsit


    Yes, there is no alternative to using setData. Mojang started to change to using string names instead of data values, but they haven't changed fully, so no alternatives.
  10. sothatsit


    I thought the question was pretty clear.
    • Agree Agree x 1
  11. no i didn't but ok.. thanks for helping anyways
    • Like Like x 1
  12. Yep correct :)
  13. Slightly sleep deprivated so please excuse me! XD