how to stop mobs from getting pushed out of walls

i've been working on an ice spell that makes an ice cube around a mob but the mob always just gets pushed out, is there any way to stop this?

Continue to help post