Section 144 of the Legal Aid, Sentencing and Punishment of Offenders Act (LASPO) makes this very clear:

144 Offence of squatting in a residential building

(1)A person commits an offence if —

(a) the person is in a residential building as a trespasser having entered...