code: @SuppressWarnings("deprecation")
  	public static IBlockState getStateFromItemStack(ItemStack itemStack)
  	{
  		if (itemStack.isEmpty())
  			return null;
  
  		Block block = Block.getBlockFromItem(itemStack.getItem());
  		if (block == null)
  			return null;
  
  		if (block instanceof MalisisBlock)
  			return ((MalisisBlock) block).getStateFromItemStack(itemStack);
  
  		//special case for pistons, because Mojang.
  		if (block instanceof BlockPistonBase)
  			return block.getDefaultState();
  
  		try
  		{
  			return block.getStateFromMeta(itemStack.getItem().getMetadata(itemStack.getMetadata()));
  		}
  		catch (Exception e)
  		{
  			return block.getDefaultState();
  		}
  	}
docs: Gets a {@link IBlockState} corresponding to the specified {@link ItemStack}
  
  @param itemStack the item stack
  @return the state from item stack