How to get an Iron Golem Spawner in 1.13

I am trying to spawn in a spawner that spawns iron golems. I have tried and failed at changing the commands from previous versions to 1.13 because of the slight syntax change.

I tried to use the 1.10 command:

setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"VillagerGolem"}} 

I tried:

setblock ~ ~1 ~ minecraft:mob_spawner{SpawnData:{id:"VillagerGolem"}} replace 

in 1.13

but that crashed the game.


Solution 1:

You were very close. You had the entity ID wrong. The entity ID for the golem is villager_golem. Capitalization and the underscore matter.

This command functions properly:

/setblock ~ ~1 ~ minecraft:mob_spawner{SpawnData:{id:"minecraft:villager_golem"}} replace

Solution 2:

The above answer may have been right at that time, however, now in 1.13.2 the command for this is as follows:

/setblock ~ ~1 ~ minecraft:spawner{SpawnData:{id:"minecraft:iron_golem"}} replace