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
No, that would work. But for a safer way I'd do something like: Code:java Block b1 =b.getWorld().getBlockAt(b.getLocation().subtract(0, -3, 0));Material w = b1.getType();
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
You can't cast Block to Wool because Wool is a MaterialData, not a Block. Code: Wool wool = (Wool)bw.getState().getData();
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);
Code: BlockState state = b1.getState(); Wool wool = (Wool)state.getData(); wool.setColor(DyeColor.BLUE); state.update();