No what cost China 100 years of humiliation was cowardice when Manchu troops ran away and were shot in the back during a rout instead of using their vast numbers advantage and fighting to the death with muskets that would've taken a high casualty ratio vs rifles but nonetheless were still guns.
Zulu with wooden spears, not even muskets, still savaged the British, decades later than the Qing, because they fought to the death.
There's no perfect time to go to war, you see this everywhere. What you can do is get ready, show resolve to fight to the death so you aren't seen as an easy target, and respond properly to escalations.
There are actually two very good series on youtube about the history of the opium wars.
Cowardice was never the cause of Qing dynasty's humiliating defeat. Instead, ignorance, technological backwardness, and most importantly a political system and hierarchical bureaucracy geared to maximize the pleasure of the top and stability of their reign but oppress the telling of unpleasant truth and empowerment of the grassroots were.
"Commissar" Jin Canrong had an excellent analogy for the PH-China situation: a noisy little guy taunting Mike Tyson. If the champ even bothers to raise his fist, it's a win for the little guy. Doesn't matter if the little guy actually fights and claims a honorable defeat or simply falls to the ground as soon as seeing the fist raised and plays the victim --- the weak has everything to win since he gets nothing in the first place.
Luckily, PRC is smart enough to view and portray itself as an imperturbable and unruffled kong fu master, rather than some hotheaded muscular moron.
Think about PRC's limited number of wars. It has always followed a crouching-tiger strategy: showing restraint, allowing the opponent to make mistakes, rallying domestic support and international sympathy in this process, and waiting patiently for the right moment (when it has adequate justification for the use of violence and when the stronger hostile tigers are occupied with something else) to pounce.
And unlike the US or Russia, it actually exceled in knowing how to end wars, often event before it started them. Again, rationalized ambitions and disciplined restraint were its unique tricks.