Setting a block to another block help! (1.7.2)

Discussion in 'Plugin Development' started by boysnnoco, Dec 18, 2013.

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

    boysnnoco

    While trying to set a block to a sapling it seems that it only sets it to a regular sapling. I have tried using this:
    Code:
    ItemStack sapling = new ItemStack(Material.SAPLING,(byte)3);
    for a jungle sapling but when I try and set a block to 'sapling' it sets it to a regular sapling.
     
  2. Offline

    xTrollxDudex

    boysnnoco
    What ._.

    Blocks != ItemStacks you use setType() and setData()
     
  3. Offline

    boysnnoco

    xTrollxDudex when I am doing the block.setType() I am doing sapling.getType(); Although I have no idea how to get around that sorry for making that less apparent
     
  4. Offline

    JRL1004

    boysnnoco I think what xTrollxDudex is trying to say is, where you put "(byte) 3" to make it a jungle sapling, you need to also do setData((byte) 3) to the block so the block form is a jungle sapling.
     
  5. Offline

    boysnnoco

    JRL1004 unless I am unaware of a change to the ItemStack function this has always worked in the past for me.
     
  6. Offline

    JRL1004

    boysnnoco ... What? Blocks, just like ItemStacks, can have a data value. When you use
    Code:
    ItemStack sapling = new ItemStack(Material.SAPLING,(byte)3);
    You are saying "Make me a new ItemStack that is a sapling with a data value of 3"
    When you convert to a block, you are just doing setType(), which is saying "Make this block a sapling." By not doing Block#setData(), you are not assigning a data value like you did with the ItemStack, and therefore, you are not making the sapling a jungle sapling.
     
  7. Offline

    boysnnoco

    JRL1004 got it I haven't used the .setType() too much.
     
  8. Offline

    JRL1004

    boysnnoco You got it working now? If so, make sure you set this thread to solved.
     
Thread Status:
Not open for further replies.

Share This Page