How to summon this sequence of stacked mobs

Solution 1:

/summon MushroomCow ~ ~ ~ {ActiveEffects:[{id:14,Duration:100000,Amplifier:1,HideParticles:1}],Riding:{id:"Spider",Attributes:[{Name:"generic.maxHealth",Base:10000}],Riding:{id:"Villager",Attributes:[{Name:"generic.maxHealth",Base:10000}],Riding:{id:"Spider",Attributes:[{Name:"generic.maxHealth",Base:10000}],Riding:{id:"Bat",Attributes:[{Name:"generic.maxHealth",Base:10000}]}}}}}

Explanation:

I used a spider to separate the mobs in the end as it's exactly 1 block tall. It is invulnerable to suffocation (because it has like 10000 health).

Also, all mobs have 10000 health, so even when they are stuck in a block because of the bat, they don't die. Change health by changing the number of baseHealth in this section: Attributes:[{Name:"generic.maxHealth",Base:<HP>}]

To kill the whole stack, first off, you have to make sure all commands blocks are activated at the very same time -- exact same time, or it may result in idling totems of mob towers. Then type in the command /kill @e[type=Bat,c=1,r=<size of the field>] in command block A, /kill @e[type=Villager,c=1,r=<size of the field>] in B, /kill @e[type=Mooshroom,c=1,r=<size of the field>] in C and /kill @e[type=Spider,c=2,r=<size of the field>] in D. Then you should be able to kill the whole stack.

I don't have a computer now so I cannot check the code, but feel free to tell me if it worked or not. Thanks!