Can you summon a Mob Spawner of any type with commands? If so, how?

I know there is some way to use monster spawners another way than to use them in their natural location...I just don't know how. Especially in normal Minecraft. There has to be some command you can use.


Solution 1:

The wiki has a list of NBT data for spawners here: http://minecraft.gamepedia.com/Mob_spawner#Data_values

And a list all entity data here: http://minecraft.gamepedia.com/Chunk_format#Entity_format


The /setblock command can create a physical block in the world, adding necessary data to tile entities:

/setblock X Y Z <block ID> [Damage] [replacement method] {dataTags}

An example, where a creeper will spawn with a fuse timer of 1 tick. Any data not specified for the spawner will use the defaults.

/setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {EntityId:"Creeper",SpawnData:{Fuse:1s}}

The /give command can create a mob spawner for inventories. The BlockEntityTag tag for the item format will hold potential tile data for the block when it is placed.

/give <player> <item ID> [Count] [Damage] {dataTags}

/give @p minecraft:mob_spawner 1 0 {BlockEntityTag:{EntityId:"Creeper",SpawnData:{Fuse:1s}}}