Wool variable

Discussion in 'Plugin Development' started by desup, Feb 25, 2012.

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

    desup

    Hi, I've create block like:
    Code:
    b.getWorld().getBlockAt(b.getLocation().subtract(0, -3, 0)).setType(Material.WOOL);
    I know its wool(because I set it), and I want to put this block to the variable Wool,
    I was thinking about that, but Im not sure if this gonna work:
    Code:
    Block b1 =b.getWorld().getBlockAt(b.getLocation().subtract(0, -3, 0));
            Wool w =(Wool) b1;  
    Am I wrong and can you help me if I am?
    Thank you
     
  2. Offline

    Sir Savary

    No, that would work. But for a safer way I'd do something like:
    Code:java
    1.  
    2. Block b1 =b.getWorld().getBlockAt(b.getLocation().subtract(0, -3, 0));
    3. Material w = b1.getType();
    4.  
     
  3. Offline

    desup

    Like, Your code and then my code? Or Just Yours?
    because, I need it in Wool variable.
    Sorry, Im stupid.
    But, Thank you for reassurance :)
     
  4. Offline

    nisovin

    You can't cast Block to Wool because Wool is a MaterialData, not a Block.

    Code:
    Wool wool = (Wool)bw.getState().getData();
     
  5. Offline

    desup

    nisovin
    Thank you, but Im trying to get coloured wool, am I doing anything wrong there?:
    Code:
     Block b1 =b.getWorld().getBlockAt(b.getLocation().subtract(0, -3, 0));
                Wool w = (Wool)b1.getState().getData();
                w.setColor(DyeColor.BLUE);
     
  6. Offline

    nisovin

    Code:
    BlockState state = b1.getState();
    Wool wool = (Wool)state.getData();
    wool.setColor(DyeColor.BLUE);
    state.update();
    
     
  7. Offline

    hammale

    cant you just set the data value with block.setData(byte) ?
     
Thread Status:
Not open for further replies.

Share This Page