It was Mencius who attacked Mohism at first, not the court. At that time, Confucianism was declining, and Mencius, as a saint, naturally wanted to revive the glory of Confucianism. Mencius, on the other hand, made a fierce attack on Mohism, which was famous at that time. Mencius, what does he think Mohism said? Love? Although it loves everyone in the world extensively, it is actually a person who doesn't love the world. And in Mohism? Love? In the cognition of this theory, the necessary relations such as monarch and father are ignored, so Mencius thinks that the core part of Mohism is actually no different from cult, so the ruler needs a stick to kill Mohism.
It is worth mentioning that all the debating skills of Mencius were learned from Mozi, and Mozi himself was the leader of Mohism. Unfortunately, the debate level of Mohist school in later generations was completely inferior to that of Mencius, so Mohist school was quickly defeated by Mencius' sophistry. But strictly speaking, Mohism can be defeated by Mencius' sophistry because Mohism is different from the imperial court.
Mohist thought is that the country should establish a unified ideological system, everyone listens to the son of heaven, and what the son of heaven says is what it is, which seriously hinders the progress of thought. Although Confucius once said? The gentleman is harmonious but different, and the villain is not harmonious? However, this is still maintained under the independence of the individual, and in Mohist theory, the individual does not need to maintain independence at all, so this idea is completely out of line with the society at that time, and naturally it has been eliminated by the times.