The balance of power between the United States and China had shifted in Beijing’s favor even before the war in Iran began in February.