first make a cage (or whatever you want) with fence
just gonna spawn some pigs...
and put carpet on top! mobs will not recognize carpet as a block so they won't jump on to carpet, but you can.
as you see i can simply jump on carpet in survival without flying. in and out, how easy!