How do I get and set the metadata value for a block item in Minecraft?


I'm writing a Minecraft module using Minecraft Forge.

I can retrieve a Block object from the world, using

Block b = world.getBlock(x,y,z);

however, now that I have the block, how do I find out the metadata? If the block is a StoneSteps block, then I want to know it's orientation, which is held in the metadata.

Similarly, how do I set this value? I can create a new block simply enough:

Block b = Blocks.stone_stairs;

but again, how do I now set this block to a particular orientation? I know you can do this when creating an ItemStack, but in this case, I want a Block object that can be passed on to world.setBlock().

There does not appear to be any way I can find to get and set this value.

You can use world.getBlockState(BlockPos); for Minecraft 1.8 or getBlockMetadata(int x, int y, int z); for Minecraft 1.7.10.