I thought at this point China and the USSR were pretty good allies.
Ok, so as /u/DeSoulis mentioned, the Chinese were not allies by the time that 1979 rolled around. There are a number of reasons for this, but before I dive into answering your question in a more detailed way, just consider this: While China and Russia share a long border, the vast majority of Chinese people live near the east coast on the Pacific, and a vast majority of Russian people live on the western edge of Russia, near Europe. While yes, these two are neighbors, Beijing and Moscow are over 3,500 miles apart. They have different cultures, different languages, vastly different histories (and the history that they do share is not very pleasant), different religions, and, even today, very different strategic aims. While the two have found common cause in the past, such as a brief common desire to promote communism, the two are simply not natural allies. Both are interested in being the head honchos in their own worlds. Mao did not want to be subservient to Stalin or Khrushchev, and Stalin+other Soviet leaders were really ticked off about being dragged into China's conflicts in Asia. In the 1950s, the Soviets were not very happy about almost going to nuclear war over the tiny islands of Quemoy and Matsu, which the Soviets simply did not care about. The Chinese were also very upset over the Korean War, but that's a whole other can of worms.
So that's kind of the broader strategic issue between the USSR and China. Now let's go into some recent areas in which the two countries had been at odds:
-In 1964, China had a short war with India, which although not aligned with the USSR, was much closer to the USSR than it was to the US or China. In some respects, this was viewed as something of a proxy war between the PRC and the USSR.
-In 1971, China began opening up to the United States. This was (correctly) seen in the USSR as China's way of throwing its weight around to back the US against the USSR in the cold war.
-China and the Soviets were at odds throughout the entirety of the Vietnam War. Despite the fact that all three were communists, China DID NOT LIKE that the North Vietnamese were so close to the USSR, because China (correctly) felt that they could later be used against China and its allies.
-In 1978 (it started a bit earlier but really broke out in 1979) the Communist Vietnamese attacked and occupied Chinese-aligned Cambodia. China interpreted this as a Soviet-designed strategy to encircle China.
-In 1979, China invaded Vietnam due to the occupation of Cambodia. This further deteriorated Sino-Soviet relations.
So to step back, in the span of a few decades we see what are interpreted as Sino-Soviet proxy wars in India, Vietnam, and Cambodia. You also have a massive Soviet troop presence, with occasional skirmishes, on China's northern border. In China and elsewhere, many people considered the invasion of Afghanistan to be part of a larger strategy to attack Pakistan and to achieve conquest of a warm water port on the Indian Ocean - long considered a major objective of Russian grand strategy. Take a look at a contemporary map and there is a simple conclusion that you would draw if you were a leader in Beijing - that you were being encircled.
Given that context, I hope that you see why it would make sense for the PRC to assist the Mujihadeen.
No, the PRC and the Soviets decisively split during the 1960s and even fought a brief border war in 1969 and a proxy-esque war in 1979 against Vietnam. By the 1970s both Mao and Deng identified the Soviet Union as China's greatest threat and that was a major cause of why Mao decided to realign the PRC with the US in 1972. During the 1980s China portrayed the Soviet Union as a massive threat which desired world domination and opposed detente as harshly as any conservative politician in the US did. The Chinese supplied approximately 3/4 of the weapons given to Afghan insurgents during the Soviet occupation largely because its government identified the Soviet Union to be the principle geopolitical threat to China.